Where is history?

So there is a difference in the usage. Okay.
Yes, that's it. Although they both refer to the exact same executable, the way that executable works is different depending on the way it is being called.

Code:
root@armitage:/tmp # ls -li someexe blah
316 -rwxr-xr-x  2 root  wheel  139 Mar  9 16:49 blah
316 -rwxr-xr-x  2 root  wheel  139 Mar  9 16:49 someexe
root@armitage:/tmp # ./blah
Running in 'blah' mode
root@armitage:/tmp # ./someexe
Running in normal mode
root@armitage:/tmp # cat someexe
#!/bin/sh

MYNAME=$(basename "$0")

if [ $MYNAME = 'blah' ]; then
  echo "Running in 'blah' mode"
else
  echo "Running in normal mode"
fi
Simplest example I could think of. Both someexe and blah refer to the same file (the inodes are the same). The code checks how it's being called (that's stored in $0 in shell, in C it would be in argv[0]).
 
the shell acts different when run as csh or tcsh
all* the stuff in /rescue is just one binary and they act different

also on most linux systems /bin/sh is linked to bash but acts more posix and without bash-isms

FWIW, on Linux Mint, and, I'm pretty sure, all of the Debian branch, /bin/sh links to dash (the Debian Almquist shell):
Code:
len@lenovo:~$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Apr  5  2021 /bin/sh -> dash
len@lenovo:~$ which dash
/usr/bin/dash
len@lenovo:~$

 
Back
Top