From 34a1a05a7948a4c00beea68fc181d8a6b45a5aab Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 5 May 1995 01:02:55 -0800 Subject: [PATCH] merged netbsd changes SCCS-vsn: bin/sh/Makefile 8.3 SCCS-vsn: bin/sh/nodes.c.pat 8.2 SCCS-vsn: bin/sh/mkbuiltins 8.2 SCCS-vsn: bin/sh/arith.y 8.3 SCCS-vsn: bin/sh/sh.1 8.6 SCCS-vsn: bin/sh/arith_lex.l 8.3 SCCS-vsn: bin/sh/builtins.def 8.4 --- usr/src/bin/sh/Makefile | 2 +- usr/src/bin/sh/arith.y | 7 +- usr/src/bin/sh/arith_lex.l | 5 +- usr/src/bin/sh/builtins.def | 11 +-- usr/src/bin/sh/mkbuiltins | 20 ++++-- usr/src/bin/sh/nodes.c.pat | 138 +++++++++++++++++------------------- usr/src/bin/sh/sh.1 | 11 +-- 7 files changed, 101 insertions(+), 93 deletions(-) diff --git a/usr/src/bin/sh/Makefile b/usr/src/bin/sh/Makefile index 63ebbdeddf..9e9c214abb 100644 --- a/usr/src/bin/sh/Makefile +++ b/usr/src/bin/sh/Makefile @@ -1,4 +1,4 @@ -# @(#)Makefile 8.4 (Berkeley) %G% +# @(#)Makefile 8.3 (Berkeley) %G% PROG= sh SRCS= alias.c builtins.c cd.c echo.c error.c eval.c exec.c expand.c \ diff --git a/usr/src/bin/sh/arith.y b/usr/src/bin/sh/arith.y index a36d9ec89b..492535879b 100644 --- a/usr/src/bin/sh/arith.y +++ b/usr/src/bin/sh/arith.y @@ -64,7 +64,7 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; } */ #ifndef lint -static char sccsid[] = "@(#)arith.y 8.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) %G%"; #endif /* not lint */ #include "shell.h" @@ -74,6 +74,7 @@ static char sccsid[] = "@(#)arith.y 8.2 (Berkeley) %G%"; char *arith_buf, *arith_startbuf; +int arith(s) char *s; { @@ -89,10 +90,10 @@ arith(s) return (result); } +void yyerror(s) char *s; { - extern yytext, yylval; yyerrok; yyclearin; @@ -103,7 +104,9 @@ yyerror(s) /* * The exp(1) builtin. */ +int expcmd(argc, argv) + int argc; char **argv; { char *p; diff --git a/usr/src/bin/sh/arith_lex.l b/usr/src/bin/sh/arith_lex.l index 4761488a03..746adae872 100644 --- a/usr/src/bin/sh/arith_lex.l +++ b/usr/src/bin/sh/arith_lex.l @@ -10,10 +10,12 @@ */ #ifndef lint -static char sccsid[] = "@(#)arith_lex.l 8.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) %G%"; #endif /* not lint */ +#include #include "y.tab.h" +#include "error.h" extern yylval; extern char *arith_buf, *arith_startbuf; @@ -50,6 +52,7 @@ extern char *arith_buf, *arith_startbuf; . { error("arith: syntax error: \"%s\"\n", arith_startbuf); } %% +void arith_lex_reset() { YY_NEW_FILE; } diff --git a/usr/src/bin/sh/builtins.def b/usr/src/bin/sh/builtins.def index 01b133823c..3b965f2132 100644 --- a/usr/src/bin/sh/builtins.def +++ b/usr/src/bin/sh/builtins.def @@ -8,12 +8,14 @@ # # %sccs.include.redist.sh% # -# @(#)builtins.def 8.3 (Berkeley) %G% +# @(#)builtins.def 8.4 (Berkeley) %G% # # 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. The rest of the line +# 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. @@ -35,7 +37,7 @@ expcmd exp let exportcmd export readonly #exprcmd expr test [ falsecmd false -histcmd fc +histcmd -h fc fgcmd -j fg getoptscmd getopts hashcmd hash @@ -44,7 +46,7 @@ jobscmd jobs #linecmd line localcmd local #nlechocmd nlecho -printfcmd printf +#printfcmd printf pwdcmd pwd readcmd read returncmd return @@ -59,3 +61,4 @@ unsetcmd unset waitcmd wait #foocmd foo aliascmd alias +ulimitcmd ulimit diff --git a/usr/src/bin/sh/mkbuiltins b/usr/src/bin/sh/mkbuiltins index e36e888f44..fc3af8068c 100644 --- a/usr/src/bin/sh/mkbuiltins +++ b/usr/src/bin/sh/mkbuiltins @@ -8,14 +8,20 @@ # # %sccs.include.redist.sh% # -# @(#)mkbuiltins 8.1 (Berkeley) %G% +# @(#)mkbuiltins 8.2 (Berkeley) %G% temp=/tmp/ka$$ havejobs=0 if grep '^#define JOBS[ ]*1' shell.h > /dev/null then havejobs=1 fi -exec > obj/builtins.c +havehist=1 +if [ "X$1" = "X-h" ]; then + havehist=0 + shift +fi +objdir=$1 +exec > ${objdir}/builtins.c cat <<\! /* * This file was generated by the mkbuiltins program. @@ -25,8 +31,8 @@ cat <<\! #include "builtins.h" ! -awk '/^[^#]/ {if('$havejobs' || $2 != "-j") print $0}' builtins | - sed 's/-j//' > $temp +awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ + print $0}' builtins.def | sed 's/-j//' > $temp awk '{ printf "int %s();\n", $1}' $temp echo ' int (*const builtinfunc[])() = {' @@ -35,12 +41,12 @@ echo '}; const struct builtincmd builtincmd[] = {' awk '{ for (i = 2 ; i <= NF ; i++) { - printf "\t\"%s\", %d,\n", $i, NR-1 + printf "\t{ \"%s\", %d },\n", $i, NR-1 }}' $temp -echo ' NULL, 0 +echo ' { NULL, 0 } };' -exec > obj/builtins.h +exec > ${objdir}/builtins.h cat <<\! /* * This file was generated by the mkbuiltins program. diff --git a/usr/src/bin/sh/nodes.c.pat b/usr/src/bin/sh/nodes.c.pat index 8a6ca83cf4..4bcc544fbe 100644 --- a/usr/src/bin/sh/nodes.c.pat +++ b/usr/src/bin/sh/nodes.c.pat @@ -7,9 +7,10 @@ * * %sccs.include.redist.c% * - * @(#)nodes.c.pat 8.1 (Berkeley) %G% + * @(#)nodes.c.pat 8.2 (Berkeley) %G% */ +#include /* * Routine for dealing with parsed shell commands. */ @@ -21,31 +22,19 @@ #include "mystring.h" -int funcblocksize; /* size of structures in function */ -int funcstringsize; /* size of strings in node */ -#ifdef __STDC__ +int funcblocksize; /* size of structures in function */ +int funcstringsize; /* size of strings in node */ pointer funcblock; /* block to allocate function from */ -#else -char *funcblock; /* block to allocate function from */ -#endif -char *funcstring; /* block to allocate strings from */ +char *funcstring; /* block to allocate strings from */ %SIZES -#ifdef __STDC__ -STATIC void calcsize(union node *); -STATIC void sizenodelist(struct nodelist *); -STATIC union node *copynode(union node *); -STATIC struct nodelist *copynodelist(struct nodelist *); -STATIC char *nodesavestr(char *); -#else -STATIC void calcsize(); -STATIC void sizenodelist(); -STATIC union node *copynode(); -STATIC struct nodelist *copynodelist(); -STATIC char *nodesavestr(); -#endif +STATIC void calcsize __P((union node *)); +STATIC void sizenodelist __P((struct nodelist *)); +STATIC union node *copynode __P((union node *)); +STATIC struct nodelist *copynodelist __P((struct nodelist *)); +STATIC char *nodesavestr __P((char *)); @@ -55,85 +44,86 @@ STATIC char *nodesavestr(); union node * copyfunc(n) - union node *n; - { - if (n == NULL) - return NULL; - funcblocksize = 0; - funcstringsize = 0; - calcsize(n); - funcblock = ckmalloc(funcblocksize + funcstringsize); - funcstring = funcblock + funcblocksize; - return copynode(n); + union node *n; +{ + if (n == NULL) + return NULL; + funcblocksize = 0; + funcstringsize = 0; + calcsize(n); + funcblock = ckmalloc(funcblocksize + funcstringsize); + funcstring = funcblock + funcblocksize; + return copynode(n); } STATIC void calcsize(n) - union node *n; - { - %CALCSIZE + union node *n; +{ + %CALCSIZE } STATIC void sizenodelist(lp) - struct nodelist *lp; - { - while (lp) { - funcblocksize += ALIGN(sizeof (struct nodelist)); - calcsize(lp->n); - lp = lp->next; - } + struct nodelist *lp; +{ + while (lp) { + funcblocksize += ALIGN(sizeof(struct nodelist)); + calcsize(lp->n); + lp = lp->next; + } } STATIC union node * copynode(n) - union node *n; - { - union node *new; + union node *n; +{ + union node *new; - %COPY - return new; + %COPY + return new; } STATIC struct nodelist * copynodelist(lp) - struct nodelist *lp; - { - struct nodelist *start; - struct nodelist **lpp; - - lpp = &start; - while (lp) { - *lpp = funcblock; - funcblock += ALIGN(sizeof (struct nodelist)); - (*lpp)->n = copynode(lp->n); - lp = lp->next; - lpp = &(*lpp)->next; - } - *lpp = NULL; - return start; + struct nodelist *lp; +{ + struct nodelist *start; + struct nodelist **lpp; + + lpp = &start; + while (lp) { + *lpp = funcblock; + funcblock += ALIGN(sizeof(struct nodelist)); + (*lpp)->n = copynode(lp->n); + lp = lp->next; + lpp = &(*lpp)->next; + } + *lpp = NULL; + return start; } STATIC char * nodesavestr(s) - char *s; - { - register char *p = s; - register char *q = funcstring; - char *rtn = funcstring; - - while (*q++ = *p++); - funcstring = q; - return rtn; + char *s; +{ + register char *p = s; + register char *q = funcstring; + char *rtn = funcstring; + + while ((*q++ = *p++) != '\0') + continue; + funcstring = q; + return rtn; } @@ -144,8 +134,8 @@ nodesavestr(s) void freefunc(n) - union node *n; - { - if (n) - ckfree(n); + union node *n; +{ + if (n) + ckfree(n); } diff --git a/usr/src/bin/sh/sh.1 b/usr/src/bin/sh/sh.1 index a3b82183cd..56b9629e4f 100644 --- a/usr/src/bin/sh/sh.1 +++ b/usr/src/bin/sh/sh.1 @@ -6,7 +6,7 @@ .\" .\" %sccs.include.redist.man% .\" -.\" @(#)sh.1 8.5 (Berkeley) %G% +.\" @(#)sh.1 8.6 (Berkeley) %G% .\" .na .TH SH 1 @@ -1002,6 +1002,12 @@ that can't be performed by a separate process. In addition to these, there are s be builtin for efficiency (e.g. printf(1), echo(1), test(1), etc). .TP +: +A null command that returns a 0 (true) exit value. +.TP +\&. file +The commands in the specified file are read and executed by the shell. +.TP alias [ name[=string] ... ] If name=string is specified, the shell defines the alias ``name'' with value ``string''. If just ``name'' @@ -1030,9 +1036,6 @@ different from the name that the user gave. These may be different either because the CDPATH mechanism was used or because a symbolic link was crossed. .TP -\&. file -The commands in the specified file are read and executed by the shell. -.TP eval string... Concatenate all the arguments with spaces. Then re-parse and execute the command. -- 2.20.1