Date: Wed, 24 Jun 2009 22:04:04 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r194922 - in head: bin/sh tools/regression/bin/sh/builtins Message-ID: <200906242204.n5OM44Kx031369@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Wed Jun 24 22:04:04 2009 New Revision: 194922 URL: http://svn.freebsd.org/changeset/base/194922 Log: 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) Modified: head/bin/sh/exec.c head/bin/sh/sh.1 head/tools/regression/bin/sh/builtins/command5.0.stdout Modified: head/bin/sh/exec.c ============================================================================== --- head/bin/sh/exec.c Wed Jun 24 21:56:05 2009 (r194921) +++ head/bin/sh/exec.c Wed Jun 24 22:04:04 2009 (r194922) @@ -756,6 +756,7 @@ typecmd_impl(int argc, char **argv, int 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 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; Modified: head/bin/sh/sh.1 ============================================================================== --- head/bin/sh/sh.1 Wed Jun 24 21:56:05 2009 (r194921) +++ head/bin/sh/sh.1 Wed Jun 24 22:04:04 2009 (r194922) @@ -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 sc 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 Modified: head/tools/regression/bin/sh/builtins/command5.0.stdout ============================================================================== --- head/tools/regression/bin/sh/builtins/command5.0.stdout Wed Jun 24 21:56:05 2009 (r194921) +++ head/tools/regression/bin/sh/builtins/command5.0.stdout Wed Jun 24 22:04:04 2009 (r194922) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906242204.n5OM44Kx031369>