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)
This commit is contained in:
Jilles Tjoelker 2009-06-24 22:04:04 +00:00
parent 2975f78738
commit 30268dfa3f
3 changed files with 16 additions and 4 deletions

View file

@ -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;

View file

@ -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

View file

@ -2,7 +2,7 @@ ls is /bin/ls
true is a shell builtin
/bin/ls is /bin/ls
fun is a shell function
break is a shell builtin
break is a special shell builtin
if is a shell keyword
{ is a shell keyword
foo is an alias for bar