Created
November 3, 2016 07:16
-
-
Save snaewe/79734a6709c0a0bd95c68263d99f652b to your computer and use it in GitHub Desktop.
run anything under sudo
This file contains 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
#!/bin/bash | |
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin | |
case ${0##*/} in | |
sudify) | |
if [ $# -eq 1 ]; then | |
pushd ${0%/*} > /dev/null | |
if [ -e $1 ]; then | |
echo "ERROR: Can't sudify $1" | |
popd > /dev/null | |
exit 1 | |
else | |
ln -s sudify $1 | |
fi | |
popd > /dev/null | |
else | |
echo "sudify <command>" | |
exit 1 | |
fi | |
;; | |
*) | |
$(which sudo) $(which ${0##*/}) $@ | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment