That was exactly the implementation of /bin/true in Unix v7: <https://github.com/v7unix/v7unix/blob/master/v7/bin/true>
That was exactly the implementation of /bin/true in Unix v7: <https://github.com/v7unix/v7unix/blob/master/v7/bin/true>
You always have to read the inode to determine whether the file is executable. The inode included the locations of the first "direct" blocks of the file's contents. So if the file is empty you know that immediately.
If the file even had a single comment line, it would mean having to do a disk seek to read it. So it would effectively double the disk I/O needed to run "/bin/true"
Here's the most recent, with the most comments: https://news.ycombinator.com/item?id=28257666
Edit: I was wrong, it is actually GNU 'yes': https://www.teddit.net/r/unix/comments/6gxduc/how_is_gnu_yes...
[1] Which is a valid assumption, as it's often the default (not sure if it's POSIX[2]), e.g. this gets clearly executed by my shell despite not having a shebang or anything else:
echo 'echo $SHELL' > /tmp/foo; chmod +x /tmp/foo; /tmp/foo
[2] Edit: It is POSIX, I know now because there's a whole subthread about it further down, that even quotes the standard, thanks gnarula.> write(2, "strace: exec: Exec format error\n", 32strace: exec: Exec format error
So the empty file is not exec()able. I think it can only be invoked from a shell.
subprocess.call("/tmp/foo", shell=xxxx) demonstrates it.
I wonder if that was the case for Unix v7 that had it zero length? (...mentioned in another thread.)
I'd say it isn't (and the same goes for false); but whether it's patentable is more debatable.