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 <vendion@gmail.com>
This commit is contained in:
Adam Jimerson 2020-08-19 08:33:33 -04:00
parent 7628a1b61d
commit a13311feac
No known key found for this signature in database
GPG Key ID: B66652C8DA531A49
1 changed files with 2 additions and 1 deletions

3
yadm
View File

@ -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