Closed berlincount closed 5 years ago
Argh, even here we are in gnu/posix hell (thanks, apple); some time ago, I (obviously) replaced the posix variant of stat with the gnu version (via brew, I think):
% uname
Darwin
% stat -f "%u" /
stat: cannot read file system information for '%u': No such file or directory
File: "/"
ID: 100000500000018 Namelen: ? Type: apfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 244199454 Free: 9954358 Available: 7930721
Inodes: Total: 9223372036854775807 Free: 9223372036851371058
% stat -c "%u" /
0
so, gstat
? :)
please provide actionable feedback.
so on my Mac I use the gnu stat, and thus the check with "uname" is misleading... what about something like this?
stat -c %u / >& /dev/null && STATCMD="stat -c" || STATCMD="stat -f"
perfectly horrible :D doesn't really make obvious what's going on, tbh.
I consider your way of overriding the system stat
risking breakage and would rather not adapt for what I'd consider "special circumstances" of your system ...
The circumstances aren't sooo special here on my Mac: in fact the brew package manager supports replacing the ages-old posix tools with the commonly used gnu tools. So rather than relying on the system name, I prefer checking the tool directly, as one-liner or as if-then statement...
What is your system, btw... and how does the error message looks like?
... it's less a matter of 'ages-old', and more of license choice. most of the brew stuff is GNU licensed, while most of the Darwin-stuff is based on BSD tools, which you'll also find on *BSD.
My system is a current MacOS Mojave with brew
.
~/src/github.com/arnehilmann/markdeck/example$ ./start
stat: illegal option -- c
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
./start: line 5: [: -eq: unary operator expected
stat: illegal option -- c
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
Recreating example_markdeck_1 ...
[...]
I think it would be better to not rely on GNU extensions altogether. Hmm.
My system is a current MacOS Mojave with
brew
.
same here
I think it would be better to not rely on GNU extensions altogether. Hmm.
yes... and no: the standard stat
tool on linux systems is the gnu version, not bsd.
so the scaffold
script should work with
1) stat (gnu: linux, macOS with gnu tools replacing bsd tools, [windows?])
2) stat (bsd: macos-vanilla)
3) gstat (gnu: macOS with gnu tools added)
sigh
Fixed ;)
On Darwin/MacOS, that
stat
call has a somewhat different syntax, as GNU/Linux uses GNU extensions instead of POSIX syntax.While using
gstat
would be possible, this PR usesls
without GNU extensions, fixing the problem of./start
complaining about argument errors.