On Thu, 7 May 2020 01:02:55 +0800, David Crayford wrote: >> >> On 2020-05-06 11:32 PM, Kirk Wolf wrote: >>> Not so fast: cp and cat are both /bin/sh built-in commands ( documented >>> under "Built-in commands" in the command reference for sh). So the shell >>> does employ DDs;-) >> >> I didn't know that! I thought they were binaries in /bin! Thanks ;) > >TS8004:/u/ts8004/rtehome: >type cat >cat is /bin/cat >TS8004:/u/ts8004/rtehome: >sh >TS8004:/u/ts8004/rtehome: >type cat >cat is a built-in command > What's "sh": type sh; echo $0; echo $SHELL; etc.
Per POSIX, if a search of directories in $PATH does not find "cat" first in /bin (i.e. elsewhere or not at all), it will not be recognized as a builtin. This is to allow users to override builtins by providing alternatives in private directories. And POSIX requires that many builtins be available via exec(). z/OS takes a deplorable shortcut by making those a multi-linked shell script which invokes sh to call the builtin. Try "ls -li /bin/echo /bin/cat" and "ls -li /bin/echo /bin/cat". The deviant side effect is that those little scripts invoke the caller's $ENV script with its side effects. Try "(cd /bin && type *) | grep built-in". -- gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN