From a13311feac2cd7d27c1ea9075467507624a055f5 Mon Sep 17 00:00:00 2001 From: Adam Jimerson Date: Wed, 19 Aug 2020 08:33:33 -0400 Subject: [PATCH] Adjust file mode check for BSD based systems Adjusts the file mode check for BSD based systems as default BSD stat uses "-f '%p'" to report the file mode. Also since `stat -p '%p' "$filename"` reports more information than just read, write, execute perms, pipe the output through `cut` to grab only the last three digits. Signed-off-by: Adam Jimerson --- yadm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yadm b/yadm index a03e769..f5ad123 100755 --- a/yadm +++ b/yadm @@ -1944,7 +1944,8 @@ function get_mode { mode=$(stat -c '%a' "$filename" 2>/dev/null) if [ -z "$mode" ] ; then # BSD-style - mode=$(stat -f '%A' "$filename" 2>/dev/null) + # Using the `cut` command to match the output of GNU stat output + mode=$(stat -f '%p' "$filename" | cut -c4-6 2>/dev/null) fi # only accept results if they are octal