New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementation of /bin/true #1

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@geocar

geocar commented Mar 11, 2016

No description provided.

@mystor

This comment has been minimized.

Show comment
Hide comment
@mystor

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!

Owner

mystor commented Mar 11, 2016

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 mystor closed this Mar 11, 2016

@geocar

This comment has been minimized.

Show comment
Hide comment
@geocar

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 [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.

@mystor

This comment has been minimized.

Show comment
Hide comment
@mystor

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.

Owner

mystor commented Mar 11, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment