summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-06-24 22:04:04 +0000
committerjilles <jilles@FreeBSD.org>2009-06-24 22:04:04 +0000
commit1f2b1b2840fc50dc3796a1eada55b57d93f00316 (patch)
treeb2b71888536e7b14e65bf309d1ee0ac2a344fa2b /bin
parenta1a0aeecefccffed1c3ed1b149fcb87763a1e05d (diff)
downloadFreeBSD-src-1f2b1b2840fc50dc3796a1eada55b57d93f00316.zip
FreeBSD-src-1f2b1b2840fc50dc3796a1eada55b57d93f00316.tar.gz
Designate special builtins as such in command -V and type.
Also document various properties of special builtins that we implement. Approved by: ed (mentor) (implicit)
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/exec.c4
-rw-r--r--bin/sh/sh.114
2 files changed, 15 insertions, 3 deletions
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index 8989ead..3dc8895 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -756,6 +756,7 @@ typecmd_impl(int argc, char **argv, int cmd)
if ((cmdp = cmdlookup(argv[i], 0)) != NULL) {
entry.cmdtype = cmdp->cmdtype;
entry.u = cmdp->param;
+ entry.special = cmdp->special;
}
else {
/* Finally use brute force */
@@ -804,6 +805,9 @@ typecmd_impl(int argc, char **argv, int cmd)
case CMDBUILTIN:
if (cmd == TYPECMD_SMALLV)
out1fmt("%s\n", argv[i]);
+ else if (entry.special)
+ out1fmt("%s is a special shell builtin\n",
+ argv[i]);
else
out1fmt("%s is a shell builtin\n", argv[i]);
break;
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index d3ae24f..461c3ca 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -606,6 +606,12 @@ This all occurs within the current shell.
.Pp
Shell built-in commands are executed internally to the shell, without
spawning a new process.
+There are two kinds of built-in commands: regular and special.
+Assignments before special builtins persist after they finish
+executing and assignment errors, redirection errors and certain
+operand errors cause a script to be aborted.
+Both regular and special builtins can affect the shell in ways
+normal programs cannot.
.Pp
Otherwise, if the command name does not match a function
or built-in command, the command is searched for as a normal
@@ -885,7 +891,7 @@ loops.
The
.Ic continue
command continues with the next iteration of the innermost loop.
-These are implemented as built-in commands.
+These are implemented as special built-in commands.
.Pp
The syntax of the
.Ic case
@@ -1001,7 +1007,7 @@ It terminates the current executional scope, returning from the previous
nested function, sourced script, or shell instance, in that order.
The
.Ic return
-command is implemented as a built-in command.
+command is implemented as a special built-in command.
.Ss Variables and Parameters
The shell maintains a set of parameters.
A parameter
@@ -1590,6 +1596,7 @@ where
is either
the path name to
.Ar utility ,
+a special shell builtin,
a shell builtin,
a shell function,
a shell keyword
@@ -2114,7 +2121,8 @@ Interpret each
.Ar name
as a command and print the resolution of the command search.
Possible resolutions are:
-shell keyword, alias, shell built-in command, command, tracked alias
+shell keyword, alias, special shell builtin, shell builtin, command,
+tracked alias
and not found.
For aliases the alias expansion is printed;
for commands and tracked aliases
OpenPOWER on IntegriCloud