dotfiles
dotfiles copied to clipboard
Replace `wc` by `stat` in `gz`
fixes #1042 . Only did 1 unit test, I haven't tested the whole fn
Thanks to your issue (#1042), I just found out that stat -c
is GNU, but that macOS/FreeBSD use stat -f
. Also, their format flags don’t match (!) but these both return file size:
# GNU
stat -c '%s' file
# macOS/FreeBSD
stat -f '%z' file
But a heads up, you should add the -L
argument (same on both platforms) so that even calling a symlink returns the results you want.
stat -c
is GNU, but that macOS/FreeBSD usestat -f
. Also, their format flags don’t match
Thank you for the info! I'll try to make it cross-platform
But a heads up, you should add the
-L
argument (same on both platforms) so that even calling a symlink returns the results you want.
That's also useful. I forgot about symlinks
I'm getting an error
stat -cL '%s' -- .bash_history
# prints this...
# stat: cannot statx '%s': No such file or directory
@LucasLarson what am I doing wrong?
You want this:
stat -Lc '%s' -- .bash_history
because %s
is an argument of the -c
option.
because
%s
is an argument of the-c
option.
I forgot that flag-ordering matters in rare cases.
Fixing now!
Wait, I just noticed targz
uses both stat
s, without a uname -s
-based condition. I'll use that "hack" (not really a hack, because it's the simplest most reliable way known)
You may want to keep the -L
option dropped in 72303304b8
You may want to keep the
-L
option dropped in72303304b8
Silly me 😅. I forgot the L
when copy-pasting
Now it's ready (for real, haha)
I've been busy, and thinking of many things yesterday. It seems my cognitive load was higher than I expected. I apologize (to everyone) for the little mistakes