Sunday, December 20, 2015

The shortest version of /bin/true

It turns out that the shortest way to implement /bin/true is just
$ touch /tmp/true
$ chmod 755 /tmp/true
$ /tmp/true
$ echo $?
0
While it may seem puzzling from the first glance, it's actually makes sense - shell treats empty file as a script that does nothing but finishing successfully. In modern Linux /bin/true is an actual ELF binary, but elders say that once upon a time UNIX /bin/true was actually an empty file.

No comments:

Post a Comment