Tag Archives: make

sudo make me a sandwich

xkcd 149 – punch this in your terminal:

cat > Makefile << _EOF
all: sandwich
`echo $'\t'`@touch me
`echo $'\t'`@if [ -e me ]; then rm me; touch a; fi
`echo $'\t'`@bash -c 'if [ -e a ]; then rm a; if [ \`whoami\` == "root" ] ; then echo "Ok"; else echo "Make it yourself"; fi; else echo "...?"; fi'

After that, try telling your command line to make you a sandwich, like this:

$ make me a sandwich
Make it yourself
$ sudo make me a sandwich
[sudo] password for ivucica:

corrected on August 11 2009, to adjust for differences in Ubuntu’s shell 🙂
corrected on September 24 2015, to explicitly specify use of /bin/bash and fix breakage on Debian Jessie