Fix a bunch of little things from the previous changeset.
[pkgusr] / usr / lib / pkgusr / chmod
index 555ca3f..e1aa49e 100755 (executable)
@@ -24,16 +24,13 @@ fi
 
 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=""
@@ -46,11 +43,12 @@ done
 # $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
@@ -59,13 +57,13 @@ 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: