Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU stat -c is macOS/FreeBSD stat -f #22

Closed
LucasLarson opened this issue Mar 15, 2023 · 0 comments · Fixed by #23
Closed

GNU stat -c is macOS/FreeBSD stat -f #22

LucasLarson opened this issue Mar 15, 2023 · 0 comments · Fixed by #23
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@LucasLarson
Copy link
Owner

This works on macOS only if stat is an alias to coreutils’s stat (gstat if using Homebrew)

[ "$(stat -L -c %d:%i "${1}")" = "$(stat -L -c %d:%i "${2}")" ] && return 0 || return 1

macOS/FreeBSD stat uses -f instead of -c to format the output.

It would work with an additional test of output...

[ "$(stat -L -c %d:%i "${1}" 2>/dev/null || stat -L -f %d:%i "${1}")" = "$(stat -L -c %d:%i "${2}" 2>/dev/null || stat -L -f %d:%i "${2}")" ] && return 0 || return 1

...which somewhat less illegibly is this:

[ "$(
  stat -L -c %d:%i "${1}" 2>/dev/null ||
  stat -L -f %d:%i "${1}"
)" = "$(
  stat -L -c %d:%i "${2}" 2>/dev/null ||
  stat -L -f %d:%i "${2}"
)" ] && return 0 || return 1
@LucasLarson LucasLarson added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Mar 15, 2023
LucasLarson added a commit that referenced this issue Mar 22, 2023
use macOS/FreeBSD’s `stat -f` or GNU/uutils’s `stat -c`, to format the device and inode numbers, which fixes #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant