Skip to content

Commit eb0f78f

Browse files
committed
improve gz function
See mathiasbynens#1044
1 parent a4e4100 commit eb0f78f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stow/shell/dot-functions

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ function server() {
8585
# Compare original and gzipped file size
8686
function gz() {
8787
local origsize gzipsize ratio
88-
origsize=$(wc -c <"${1}")
88+
origsize=$(
89+
stat -Lf"%z" -- "$1" 2> /dev/null; # macOS `stat`
90+
stat -Lc"%s" -- "$1" 2> /dev/null; # GNU `stat`
91+
);
8992
gzipsize=$(gzip -c "${1}" | wc -c)
9093
ratio=$(echo "${gzipsize} * 100 / ${origsize}" | bc -l)
9194
printf "orig: %d bytes\n" "${origsize}"

0 commit comments

Comments
 (0)