| 1 |
http://www.opengroup.org/onlinepubs/9699919799/ |
| 2 |
Open Group Base Specifications Issue 7 |
| 3 |
|
| 4 |
|
| 5 |
http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html |
| 6 |
Shell & Utilities |
| 7 |
|
| 8 |
It says that any of the standard utilities may be implemented |
| 9 |
as a regular shell built-in. It gives a list of utilities which |
| 10 |
are usually implemented that way (and some of them can only |
| 11 |
be implemented as built-ins, like "alias"): |
| 12 |
|
| 13 |
alias |
| 14 |
bg |
| 15 |
cd |
| 16 |
command |
| 17 |
false |
| 18 |
fc |
| 19 |
fg |
| 20 |
getopts |
| 21 |
jobs |
| 22 |
kill |
| 23 |
newgrp |
| 24 |
pwd |
| 25 |
read |
| 26 |
true |
| 27 |
umask |
| 28 |
unalias |
| 29 |
wait |
| 30 |
|
| 31 |
|
| 32 |
http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html |
| 33 |
Shell Command Language |
| 34 |
|
| 35 |
It says that shell must implement special built-ins. Special built-ins |
| 36 |
differ from regular ones by the fact that variable assignments |
| 37 |
done on special builtin are *PRESERVED*. That is, |
| 38 |
|
| 39 |
VAR=VAL special_builtin; echo $VAR |
| 40 |
|
| 41 |
should print VAL. |
| 42 |
|
| 43 |
(Another distinction is that an error in special built-in should |
| 44 |
abort the shell, but this is not such a critical difference, |
| 45 |
and moreover, at least bash's "set" does not follow this rule, |
| 46 |
which is even codified in autoconf configure logic now...) |
| 47 |
|
| 48 |
List of special builtins: |
| 49 |
|
| 50 |
. file |
| 51 |
: [argument...] |
| 52 |
break [n] |
| 53 |
continue [n] |
| 54 |
eval [argument...] |
| 55 |
exec [command [argument...]] |
| 56 |
exit [n] |
| 57 |
export name[=word]... |
| 58 |
export -p |
| 59 |
readonly name[=word]... |
| 60 |
readonly -p |
| 61 |
return [n] |
| 62 |
set [-abCefhmnuvx] [-o option] [argument...] |
| 63 |
set [+abCefhmnuvx] [+o option] [argument...] |
| 64 |
set -- [argument...] |
| 65 |
set -o |
| 66 |
set +o |
| 67 |
shift [n] |
| 68 |
times |
| 69 |
trap n [condition...] |
| 70 |
trap [action condition...] |
| 71 |
unset [-fv] name... |
| 72 |
|
| 73 |
In practice, no one uses this obscure feature - none of these builtins |
| 74 |
gives any special reasons to play such dirty tricks. |
| 75 |
|
| 76 |
However. This section also says that *function invocation* should act |
| 77 |
similar to special built-in. That is, variable assignments |
| 78 |
done on function invocation should be preserved after function invocation. |
| 79 |
|
| 80 |
This is significant: it is not unthinkable to want to run a function |
| 81 |
with some variables set to special values. But because of the above, |
| 82 |
it does not work: variable will "leak" out of the function. |