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

Leave a Reply

Your email address will not be published.

 

What is 12 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

This site uses Akismet to reduce spam. Learn how your comment data is processed.