Site icon ivucica blog

sudo make me a sandwich

xkcd 149 – punch this in your terminal:

cat > Makefile << _EOF
SHELL=/bin/bash
all: sandwich
me:
`echo $'\t'`@touch me
a:
`echo $'\t'`@if [ -e me ]; then rm me; touch a; fi
sandwich:
`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'
_EOF

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:
Ok
$

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


via blog.vucica.net