Why does a program named sl (stream locomotive) always end with an exit status of "1"?
sl
Animation sl now running...
$ echo $?
1
Why not zero exit status?
Can I get an explanation? I am running it in tmux.
It's a toy program, so normal design practices don't necessarily apply. But it's open-source and the history is public, so you can look at the source. Once you've found the relevant file and line, given that the project is maintained with Git, you can use git blame to find when that line was last modified. The project is on GitHub, so you can use the “Blame” button there.
The current version (5.03+) of the original project always exits with status 0.
Previous versions (until April 2017) exited with status 0 if you compiled them with a C99 compiler. If you compiled them with a non-C99 compliant compiler, they would, on most architectures, typically end up returning the low 8 bits of whatever value was returned from the last function call done from main. Or maybe not — in versions of the C language before C99, falling off the end of main was undefined behavior. In theory, undefined behavior can cause demons to fly out of your nose, although in a Unix environment, this is constrained by the availability of the proper device and the permission to access it. In practice, on most architectures, the return value from a function that returns int is placed in a register, so the exit code of the program would be calculated from whatever value was last written to that register, which tends to be the value returned by the last non-void function call (but might not be, depending on what the exact functions are and on the compiler optimizations).
There is a somewhat prominent fork whose author decided to always return 1 “Because when you type sl you technically failed”.
alias sl=ls in my ~/.bashrc all these years.
ls's exit status in order to do something on success, well, in that case the mispelt sl should better fail.
1, or maybe the implementation you have on your system was written to always exit with1, only the developers will know for sure.slthat tries to take over the terminal. Please add that to your question.