Skip to content

Commit

Permalink
refactor(uq): use exponential operation instead of multiplication t…
Browse files Browse the repository at this point in the history
…o calculate size 🧮
  • Loading branch information
oldratlee committed Jan 26, 2024
1 parent 88d0d09 commit c260f20
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bin/uq
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c260f20

Please sign in to comment.