From 0db401540e16ebc8779d7806d228249018f618ea Mon Sep 17 00:00:00 2001 From: stefanf Date: Sun, 2 Apr 2006 18:43:33 +0000 Subject: [PATCH] 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. Obtained from: NetBSD (builtins.def part) --- bin/sh/builtins.def | 42 ++++++++++++++++++++++-------------------- bin/sh/mkbuiltins | 10 ++++++++-- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/bin/sh/builtins.def b/bin/sh/builtins.def index 8159a38e21cd..75f83b54e526 100644 --- a/bin/sh/builtins.def +++ b/bin/sh/builtins.def @@ -36,13 +36,15 @@ # # This file lists all the builtin commands. The first column is the name -# of a C routine. The -j flag, if present, specifies that this command -# is to be excluded from systems without job control, and the -h flag, -# if present specifies that this command is to be excluded from systems -# based on the NO_HISTORY compile-time symbol. The rest of the line -# specifies the command name or names used to run the command. The entry -# for bltincmd, which is run when the user does not specify a command, must -# come first. +# of a C routine. +# The -j flag specifies that this command is to be excluded from systems +# without job control. +# The -h flag specifies that this command is to be excluded from systems +# based on the NO_HISTORY compile-time symbol. +# The -s flag specifies that this is a POSIX 'special built-in' command. +# The rest of the line specifies the command name or names used to run the +# command. The entry for bltincmd, which is run when the user does not specify +# a command, must come first. # # NOTE: bltincmd must come first! @@ -50,16 +52,16 @@ bltincmd builtin aliascmd alias bgcmd -j bg bindcmd bind -breakcmd break continue +breakcmd -s break -s continue cdcmd cd chdir commandcmd command -dotcmd . +dotcmd -s . echocmd echo -evalcmd eval -execcmd exec -exitcmd exit +evalcmd -s eval +execcmd -s exec +exitcmd -s exit expcmd exp let -exportcmd export readonly +exportcmd -s export -s readonly #exprcmd expr falsecmd false fgcmd -j fg @@ -72,18 +74,18 @@ localcmd local #printfcmd printf pwdcmd pwd readcmd read -returncmd return -setcmd set +returncmd -s return +setcmd -s set setvarcmd setvar -shiftcmd shift +shiftcmd -s shift testcmd test [ -timescmd times -trapcmd trap -truecmd : true +timescmd -s times +trapcmd -s trap +truecmd -s : true typecmd type ulimitcmd ulimit umaskcmd umask unaliascmd unalias -unsetcmd unset +unsetcmd -s unset waitcmd wait wordexpcmd wordexp diff --git a/bin/sh/mkbuiltins b/bin/sh/mkbuiltins index 144505c84307..7b77649de415 100755 --- a/bin/sh/mkbuiltins +++ b/bin/sh/mkbuiltins @@ -66,9 +66,14 @@ echo '}; const struct builtincmd builtincmd[] = {' awk '{ for (i = 2 ; i <= NF ; i++) { - printf "\t{ \"%s\", %d },\n", $i, NR-1 + if ($i == "-s") { + spc = 1; + } else { + printf "\t{ \"%s\", %d, %d },\n", $i, NR-1, spc + spc = 0; + } }}' $temp -echo ' { NULL, 0 } +echo ' { NULL, 0, 0 } };' exec > ${objdir}/builtins.h @@ -85,6 +90,7 @@ echo ' struct builtincmd { char *name; int code; + int special; }; extern int (*const builtinfunc[])(int, char **);