From 8483adf8907c587ed911bb8ef9cb1b7ba5ae508e Mon Sep 17 00:00:00 2001 From: Lucas Larson Date: Mon, 20 Mar 2023 14:37:17 -0400 Subject: [PATCH 1/2] restore access to macOS/FreeBSD `stat` Signed-off-by: Lucas Larson --- bin/samefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/samefile b/bin/samefile index 1815217..9f26b94 100755 --- a/bin/samefile +++ b/bin/samefile @@ -19,9 +19,16 @@ main() { # stat # `-L` to dereference symbolic links # https://superuser.com/a/196655 - # `-c` to display %d for device and - # %i for inode - [ "$(stat -L -c %d:%i "${1}")" = "$(stat -L -c %d:%i "${2}")" ] && return 0 || return 1 + # `-c` for GNU to display %d for device and + # %i for inode + # `-f` for BSD/macOS to display %d for device and + # %i for inode + if command stat -L -c '%d:%i' -- . >/dev/null 2>&1; then + argument='-c' + else + argument='-f' + fi + [ "$(stat -L "${argument-}" %d:%i "${1}" 2>/dev/null)" = "$(stat -L "${argument-}" %d:%i "${2}")" ] && return 0 || return 1 { set +x; } 2>/dev/null } From 922023c905a64c651db85bf69614d92a8b34dd60 Mon Sep 17 00:00:00 2001 From: Lucas Larson Date: Mon, 20 Mar 2023 14:47:08 -0400 Subject: [PATCH 2/2] remove sole command-prepending `command` emulate existing style Signed-off-by: Lucas Larson --- bin/samefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/samefile b/bin/samefile index 9f26b94..5f4f720 100755 --- a/bin/samefile +++ b/bin/samefile @@ -23,7 +23,7 @@ main() { # %i for inode # `-f` for BSD/macOS to display %d for device and # %i for inode - if command stat -L -c '%d:%i' -- . >/dev/null 2>&1; then + if stat -L -c '%d:%i' -- . >/dev/null 2>&1; then argument='-c' else argument='-f'