Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upimplementation of /bin/true #1
Conversation
geocar
added some commits
Mar 11, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mystor
Mar 11, 2016
Owner
I believe that this implementation of true only works in some shells. In addition, it's not an ELF executable, so I don't think it fits in this repo. Funny though!
|
I believe that this implementation of true only works in some shells. In addition, it's not an ELF executable, so I don't think it fits in this repo. Funny though! |
mystor
closed this
Mar 11, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
geocar
Mar 11, 2016
It should work on any posix-compatible shell.
See:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01
specifically "Command Search and Execution" § 1.d.i.b:
If the execl() function fails due to an error equivalent to the [ENOEXEC] error defined in the System Interfaces volume of POSIX.1-2008, _the shell shall execute a command equivalent to having a shell invoked with the pathname resulting from the search as its first operand_, with any remaining arguments passed to the new shell, except that the value of "$0" in the new shell may be set to the command name. If the executable file is not a text file, the shell may bypass this command execution. In this case, it shall write an error message, and shall return an exit status of 126.
If my implementation of "true" doesn't work in a given shell it is clear that it is only because that shell is not POSIX compatible.
geocar
commented
Mar 11, 2016
|
It should work on any posix-compatible shell. See: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01 specifically "Command Search and Execution" § 1.d.i.b: If the execl() function fails due to an error equivalent to the If my implementation of "true" doesn't work in a given shell it is clear that it is only because that shell is not POSIX compatible. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mystor
Mar 11, 2016
Owner
This implementation of true is a shell script rather than an ELF executable. If we allow shell scripts than pretty much all of these commands can be written using only built ins in <100 characters, which kinda defeats the fun.
For example, as echo is a built in, echo $* is actually the shortest impl of echo, allowing POSIX shell scripts.
This implementation is cool, and I agree that it works in all POSIX shells, but it isn't what I was going for with this project. Sorry.
|
This implementation of true is a shell script rather than an ELF executable. If we allow shell scripts than pretty much all of these commands can be written using only built ins in <100 characters, which kinda defeats the fun. For example, as This implementation is cool, and I agree that it works in all POSIX shells, but it isn't what I was going for with this project. Sorry. |
geocar commentedMar 11, 2016
No description provided.