You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The -c flag is unique to the GNU flavor of stat and is not available in the BSD flavor of stat that is used on BSD-derived operating systems like macOS.
The BSD stat equivalent of the GNU -c%s is -f%z.
I'm not sure if there's a more portable way of discovering a file's size. If not, I'm not sure of the best way to distinguish BSD stat from GNU stat so that the right command could be used.
The text was updated successfully, but these errors were encountered:
get_filesize() {
local f v
f="$1"
# GNU stat
if v=$(stat -c%s "$f" 2>/dev/null) && echo "$v" | grep -q '^[0-9]\+$'; then
echo "$v"
return
fi
# BSD stat
stat -f%z "$f"
}
Would you like to create a PR?
wdoekes
changed the title
stat: illegal option -- c
(test suite) stat: illegal option -- c
Apr 29, 2024
When running
regress/runtests
on macOS, this error occurs in one test:It's happening on this line:
sipp/regress/github-#0337/run
Line 13 in d1bdebe
The
-c
flag is unique to the GNU flavor ofstat
and is not available in the BSD flavor ofstat
that is used on BSD-derived operating systems like macOS.The BSD
stat
equivalent of the GNU-c%s
is-f%z
.I'm not sure if there's a more portable way of discovering a file's size. If not, I'm not sure of the best way to distinguish BSD
stat
from GNUstat
so that the right command could be used.The text was updated successfully, but these errors were encountered: