From c260f204f5a47355059765ee554281e172e73146 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Fri, 26 Jan 2024 13:15:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(`uq`):=20use=20exponential=20operation?= =?UTF-8?q?=20instead=20of=20multiplication=20to=20calculate=20size=20?= =?UTF-8?q?=F0=9F=A7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/uq | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/uq b/bin/uq index d05d62b2..edf3180a 100755 --- a/bin/uq +++ b/bin/uq @@ -9,7 +9,7 @@ # # @online-doc https://github.com/oldratlee/useful-scripts/blob/dev-2.x/docs/shell.md#-uq # @author Zava Xu (zava.kid at gmail dot com) -# @author Jerry Lee (oldratlee at gmail dot com)# NOTE about Bash Traps and Pitfalls: +# @author Jerry Lee (oldratlee at gmail dot com) # # NOTE about Bash Traps and Pitfalls: # @@ -71,14 +71,14 @@ convertHumanReadableSizeToSize() { local size=${BASH_REMATCH[1]} unit=${BASH_REMATCH[2]} case "$unit" in - g) - ((size *= 1024 * 1024 * 1024)) + k) + ((size *= 1024)) ;; m) - ((size *= 1024 * 1024)) + ((size *= 1024 ** 2)) ;; - k) - ((size *= 1024)) + g) + ((size *= 1024 ** 3)) ;; esac