Skip to content

Instantly share code, notes, and snippets.

@rahulg
Created May 8, 2015 02:33
Show Gist options
  • Save rahulg/86f035c43e1636850663 to your computer and use it in GitHub Desktop.
Save rahulg/86f035c43e1636850663 to your computer and use it in GitHub Desktop.
chmod / chown wrapper
#!/usr/bin/env bash
#
# Installation:
# Copy chmow to some directory in your path, like /usr/local/bin
# cd <directory_above>
# chmod 0755 chmow
# ln -s chmow chmod
# ln -s chmow chown
set -e -u
progname=$( basename ${0} )
cmdline=${@}
for word in ${cmdline}; do
if [[ ${word} =~ [0-7]{3,4} ]]; then
progname=chmod
break
elif [[ ${word} =~ [0-9a-f]*:[0-9a-f]* ]]; then
progname=chown
break
elif [[ ${word} =~ .*/.* ]]; then
break
fi
done
/bin/${progname} ${cmdline}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment