blob: 6a9f5b6aea6b51ce8ee402632eed694251be23f2 [file] [log] [blame]
Denys Vlasenko0e81e482010-05-17 23:51:00 +02001http://www.opengroup.org/onlinepubs/9699919799/
2Open Group Base Specifications Issue 7
Denis Vlasenkoe4712752007-04-14 15:08:41 +00003
Denis Vlasenko12c06222008-02-14 08:52:30 +00004
Denys Vlasenko0e81e482010-05-17 23:51:00 +02005http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html
6Shell & Utilities
Denis Vlasenkocccdc4e2007-11-23 21:08:38 +00007
Denys Vlasenko0e81e482010-05-17 23:51:00 +02008It says that any of the standard utilities may be implemented
9as a regular shell built-in. It gives a list of utilities which
10are usually implemented that way (and some of them can only
11be implemented as built-ins, like "alias"):
Denis Vlasenkod67cef22007-06-13 06:47:47 +000012
Denys Vlasenko0e81e482010-05-17 23:51:00 +020013alias
14bg
15cd
16command
17false
18fc
19fg
20getopts
21jobs
22kill
23newgrp
24pwd
25read
26true
27umask
28unalias
29wait
Denis Vlasenkod76c0492007-05-25 02:16:25 +000030
Denis Vlasenko163a8552007-05-24 13:52:46 +000031
Denys Vlasenko0e81e482010-05-17 23:51:00 +020032http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
33Shell Command Language
Denis Vlasenko8805eeb2007-05-21 10:19:48 +000034
Denys Vlasenko0e81e482010-05-17 23:51:00 +020035It says that shell must implement special built-ins. Special built-ins
36differ from regular ones by the fact that variable assignments
Denys Vlasenko131ed3b2010-05-20 12:56:14 +020037done on special builtin are *PRESERVED*. That is,
Denis Vlasenko21f0d4c2007-05-06 14:15:42 +000038
Denys Vlasenko0e81e482010-05-17 23:51:00 +020039VAR=VAL special_builtin; echo $VAR
Denis Vlasenkoac0e5ab2007-05-04 21:37:27 +000040
Denys Vlasenko0e81e482010-05-17 23:51:00 +020041should print VAL.
Denis Vlasenko400c5b62007-05-04 13:07:27 +000042
Denys Vlasenko0e81e482010-05-17 23:51:00 +020043(Another distinction is that an error in special built-in should
44abort the shell, but this is not such a critical difference,
45and moreover, at least bash's "set" does not follow this rule,
Denys Vlasenko131ed3b2010-05-20 12:56:14 +020046which is even codified in autoconf configure logic now...)
Denis Vlasenkoe725bfe2007-05-03 22:45:39 +000047
Denys Vlasenko0e81e482010-05-17 23:51:00 +020048List of special builtins:
Denis Vlasenko08c8c1d2007-04-28 22:39:02 +000049
Denys Vlasenko0e81e482010-05-17 23:51:00 +020050. file
51: [argument...]
52break [n]
53continue [n]
54eval [argument...]
55exec [command [argument...]]
56exit [n]
57export name[=word]...
58export -p
59readonly name[=word]...
60readonly -p
61return [n]
62set [-abCefhmnuvx] [-o option] [argument...]
63set [+abCefhmnuvx] [+o option] [argument...]
64set -- [argument...]
65set -o
66set +o
67shift [n]
68times
69trap n [condition...]
70trap [action condition...]
71unset [-fv] name...
Denis Vlasenko1359da62007-04-21 23:27:30 +000072
Denys Vlasenko0e81e482010-05-17 23:51:00 +020073In practice, no one uses this obscure feature - none of these builtins
74gives any special reasons to play such dirty tricks.
Denis Vlasenko52881e92007-04-21 13:42:52 +000075
Denys Vlasenko131ed3b2010-05-20 12:56:14 +020076However. This section also says that *function invocation* should act
Denys Vlasenko0e81e482010-05-17 23:51:00 +020077similar to special built-in. That is, variable assignments
78done on function invocation should be preserved after function invocation.
Denis Vlasenko2f1bb362007-04-21 10:01:14 +000079
Denys Vlasenko0e81e482010-05-17 23:51:00 +020080This is significant: it is not unthinkable to want to run a function
81with some variables set to special values. But because of the above,
82it does not work: variable will "leak" out of the function.