Created
May 8, 2015 02:33
-
-
Save rahulg/86f035c43e1636850663 to your computer and use it in GitHub Desktop.
chmod / chown wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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