if [ $UID == 0 ]; then
echo 1>&2 '***' $(dirname $0) should not be in root\'s \$PATH
- echo 1>&2 '***' call "$DAISY_CHAIN $@" directly.
+ echo 1>&2 '***' call '"'$DAISY_CHAIN $@'"' directly.
exit 1
fi
# Save the original cmdline as we're gonna mess with it
cmdline="$@"
-reportmsg="*** chmod $cmdline"
-report=0
-
# Remove any options so $1 becomes the perm arg, however save the
# options for later
opts=""
# $1 should now be the perm arg
# Octal or symbolic?
-if [ $1 -ge 0 2>/dev/null ]; then
+printf '%d' $1 &>/dev/null
+if [ $? -eq 0 ]; then
perm=$1
else
touch /tmp/hack-o-matic-4500
- chmod $1 /tmp/hack-o-matic-4500
+ $DAISY_CHAIN $1 /tmp/hack-o-matic-4500
perm=$(stat --printf "%a" /tmp/hack-o-matic-4500)
rm -f /tmp/hack-o-matic-4500
fi
if [ $perm -gt 999 ]; then
# Chop off the 1st digit (the set{uid,gid,sticky} bit)
perm=${perm/?/}
- echo 1>&2 "$reportmsg"
+ echo 1>&2 '***' chmod ${cmdline}
fi
# kill off $1 and replace it with our maybe sanitised $perm
shift 1; set -- $perm "$@"
-exec $DAISY_CHAIN "$opts $@" || exit $?
+exec $DAISY_CHAIN ${opts} $@ || exit $?
exit 0
# Local variables: