Use -s to flag POSIX's "special built-in" utilities in builtins.def. Add a
commitc118986c72871755f755c8266948802fef98343c
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 7 Jan 2007 01:14:53 +0000 (7 01:14 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 7 Jan 2007 01:14:53 +0000 (7 01:14 +0000)
tree03634c05a3b9227aed99c10f6221f7b1be1f449f
parent3100c980e03cd39cb4c00981c5392da4a86e3c51
Use -s to flag POSIX's "special built-in" utilities in builtins.def.  Add a
new member to struct builtincmd and set it to 1 if -s was specified.  This
is done because there are cases where special builtins must be treated
differently from other builtins.

Implement some of the differences between special built-ins and other builtins
demanded by POSIX.
- A redirection error is only fatal (meaning the execution of a shell script is
  terminated) for special built-ins.  Previously it was fatal for all shell
  builtins, causing problems like the one reported in FreeBSD PR 88845.
- Variable assignments remain in effect for special built-ins.
- Option or operand errors are only fatal for special built-ins.

Add the times builtin.  It reports the user and system time for the shell
itself and its children.  Instead of calling times() (as implied by POSIX) this
implementation directly calls getrusage() to get the times because this is more
convenient.

Print pointers with %p rather than casting them to long.

Replace home-grown dup2() implementation with actual dup2() calls.  This
should slightly reduce the number of system calls in critical portions of
the shell, and select a more efficient path through the fdalloc code.

Implement the PS4 variable which is defined by the POSIX User Portability
Utilities option.  Its value is printed at the beginning of the line if tracing
(-x) is active.  PS4 defaults to the string "+ " which is compatible with the
old behaviour to always print "+ ".

Don't crash on "<cmd> | { }".

Remove some white space at EOL.

Add the POSIX options -v and -V to the 'command' builtin.  Both describe the
type of their argument, if it is a shell function, an alias, a builtin, etc.
-V is more verbose than -v.

Do not assume there is only a space between #define and the macro name
when grepping for JOBS in mkbuiltins

Obtained-from:  FreeBSD
bin/sh/builtins.def
bin/sh/eval.c
bin/sh/eval.h
bin/sh/exec.c
bin/sh/exec.h
bin/sh/mkbuiltins
bin/sh/options.c
bin/sh/sh.1
bin/sh/var.c
bin/sh/var.h