Skip to content

Instantly share code, notes, and snippets.

@Raven24
Created October 22, 2012 08:43
Show Gist options
  • Save Raven24/3930399 to your computer and use it in GitHub Desktop.
Save Raven24/3930399 to your computer and use it in GitHub Desktop.
root inhibition
#!/usr/bin/env sh
# Don't allow a given command to be run as root.
# This script will output an error message, in case the current
# user is identified as root (also works in case of 'sudo')
# do we have color ?
case "$TERM" in
xterm*|rxvt*)
read -r red RED blue BLUE cyan CYAN NC <<EOF
\033[0;31m \033[1;31m \033[0;34m \033[1;34m \033[0;36m \033[1;36m \033[0m
EOF
;;
esac
# don't allow root to run this command
if [ `whoami` = "root" ] ; then
printf "${red}don't run '${cyan}$*${red}' as ${RED}root${red}!${NC}\n"
exit 1
fi
# show time
eval $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment