On 10/08/15 05:55, Eric Blake wrote: > On 08/10/2015 02:18 AM, Juanma wrote: > >> Here is another point I find confusing: I thought a "shell builtin" didn't >> have a separate binary executable file, like 'cd' (which cd => fail), > > Actually, POSIX requires that there be a separate 'cd' binary, although > it does not have to behave the same as the shell builtin. (About all an > exec'able cd can do is tell you by exit status whether the builtin cd > would succeed or fail; or be used for its CDPATH side-effect of printing > a directory name). > > GNU/Linux systems tend to ignore the POSIX requirement of exec'able > counterparts, although here is how Solaris effectively does it: > > $ cat /bin/cd > #!/bin/sh > exec $(basename $0) "$@" > $ > > and hard-linking that 2-liner to all of the shell builtins where POSIX > requires to have a non-builtin counterpart. > > See also http://austingroupbugs.net/view.php?id=705 > > It is only the special builtins (such as 'exit') where POSIX does not > require an exec'able counterpart.
For the record I see this on Fedora 25 $ rpm -q bash bash-4.3.43-4.fc25.x86_64 $ rpm -ql bash | grep /bin/ | grep -v bash /usr/bin/alias /usr/bin/bg /usr/bin/cd /usr/bin/command /usr/bin/fc /usr/bin/fg /usr/bin/getopts /usr/bin/hash /usr/bin/jobs /usr/bin/read /usr/bin/sh /usr/bin/type /usr/bin/ulimit /usr/bin/umask /usr/bin/unalias /usr/bin/wait $ cat /usr/bin/cd #!/bin/sh builtin cd "$@" cheers, Pádraig