[type/{__file,__directory}] Fix incorrect interpretation of strings with leading 0s as octal

This commit is contained in:
Dennis Camera 2020-07-23 09:41:53 +02:00
parent 8903540e91
commit 595e43b8d5
2 changed files with 6 additions and 2 deletions

View file

@ -99,7 +99,9 @@ case "$state_should" in
# format mode in four digits => same as stat returns
if [ "$attribute" = mode ]; then
value_should=$(printf '%04u' "${value_should}")
# Convert to four-digit octal number (printf interprets
# strings with leading 0s as octal!)
value_should=$(printf '%04o' "0${value_should}")
fi
if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then

View file

@ -70,7 +70,9 @@ case "$state_should" in
# format mode in four digits => same as stat returns
if [ "$attribute" = mode ]; then
value_should=$(printf '%04u' "${value_should}")
# Convert to four-digit octal number (printf interprets
# strings with leading 0s as octal!)
value_should=$(printf '%04o' "0${value_should}")
fi
value_is="$(get_current_value "$attribute" "$value_should")"