merged netbsd changes
authorChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Fri, 5 May 1995 09:02:55 +0000 (01:02 -0800)
committerChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Fri, 5 May 1995 09:02:55 +0000 (01:02 -0800)
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
usr/src/bin/sh/arith.y
usr/src/bin/sh/arith_lex.l
usr/src/bin/sh/builtins.def
usr/src/bin/sh/mkbuiltins
usr/src/bin/sh/nodes.c.pat
usr/src/bin/sh/sh.1

index 63ebbde..9e9c214 100644 (file)
@@ -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 \
 
 PROG=  sh
 SRCS=  alias.c builtins.c cd.c echo.c error.c eval.c exec.c expand.c \
index a36d9ec..4925358 100644 (file)
@@ -64,7 +64,7 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
  */
 
 #ifndef lint
  */
 
 #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"
 #endif /* not lint */
 
 #include "shell.h"
@@ -74,6 +74,7 @@ static char sccsid[] = "@(#)arith.y   8.2 (Berkeley) %G%";
 
 char *arith_buf, *arith_startbuf;
 
 
 char *arith_buf, *arith_startbuf;
 
+int
 arith(s)
        char *s; 
 {
 arith(s)
        char *s; 
 {
@@ -89,10 +90,10 @@ arith(s)
        return (result);
 }
 
        return (result);
 }
 
+void
 yyerror(s)
        char *s;
 {
 yyerror(s)
        char *s;
 {
-       extern yytext, yylval;
 
        yyerrok;
        yyclearin;
 
        yyerrok;
        yyclearin;
@@ -103,7 +104,9 @@ yyerror(s)
 /*
  *  The exp(1) builtin.
  */
 /*
  *  The exp(1) builtin.
  */
+int
 expcmd(argc, argv)
 expcmd(argc, argv)
+       int argc;
        char **argv;
 {
        char *p;
        char **argv;
 {
        char *p;
index 4761488..746adae 100644 (file)
  */
 
 #ifndef lint
  */
 
 #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 */
 
 #endif /* not lint */
 
+#include <unistd.h>
 #include "y.tab.h"
 #include "y.tab.h"
+#include "error.h"
 
 extern yylval;
 extern char *arith_buf, *arith_startbuf;
 
 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); }
 %%
 
 .      { error("arith: syntax error: \"%s\"\n", arith_startbuf); }
 %%
 
+void
 arith_lex_reset() {
        YY_NEW_FILE;
 }
 arith_lex_reset() {
        YY_NEW_FILE;
 }
index 01b1338..3b965f2 100644 (file)
@@ -8,12 +8,14 @@
 #
 # %sccs.include.redist.sh%
 #
 #
 # %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
 
 #
 # 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.
 # 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
 exportcmd      export readonly
 #exprcmd       expr test [
 falsecmd       false
-histcmd                fc
+histcmd -h     fc
 fgcmd -j       fg
 getoptscmd     getopts
 hashcmd                hash
 fgcmd -j       fg
 getoptscmd     getopts
 hashcmd                hash
@@ -44,7 +46,7 @@ jobscmd               jobs
 #linecmd               line
 localcmd       local
 #nlechocmd     nlecho
 #linecmd               line
 localcmd       local
 #nlechocmd     nlecho
-printfcmd      printf
+#printfcmd     printf
 pwdcmd         pwd
 readcmd                read
 returncmd      return
 pwdcmd         pwd
 readcmd                read
 returncmd      return
@@ -59,3 +61,4 @@ unsetcmd      unset
 waitcmd                wait
 #foocmd                foo
 aliascmd       alias
 waitcmd                wait
 #foocmd                foo
 aliascmd       alias
+ulimitcmd      ulimit
index e36e888..fc3af80 100644 (file)
@@ -8,14 +8,20 @@
 #
 # %sccs.include.redist.sh%
 #
 #
 # %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
 
 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.
 cat <<\!
 /*
  * This file was generated by the mkbuiltins program.
@@ -25,8 +31,8 @@ cat <<\!
 #include "builtins.h"
 
 !
 #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[])() = {'
 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++) {
 
 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
        }}' $temp
-echo ' NULL, 0
+echo ' { NULL, 0 }
 };'
 
 };'
 
-exec > obj/builtins.h
+exec > ${objdir}/builtins.h
 cat <<\!
 /*
  * This file was generated by the mkbuiltins program.
 cat <<\!
 /*
  * This file was generated by the mkbuiltins program.
index 8a6ca83..4bcc544 100644 (file)
@@ -7,9 +7,10 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)nodes.c.pat 8.1 (Berkeley) %G%
+ *     @(#)nodes.c.pat 8.2 (Berkeley) %G%
  */
 
  */
 
+#include <stdlib.h>
 /*
  * Routine for dealing with parsed shell commands.
  */
 /*
  * Routine for dealing with parsed shell commands.
  */
 #include "mystring.h"
 
 
 #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 */
 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
 
 
 
 %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 *
 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)
 }
 
 
 
 STATIC void
 calcsize(n)
-      union node *n;
-      {
-      %CALCSIZE
+       union node *n;
+{
+       %CALCSIZE
 }
 
 
 
 STATIC void
 sizenodelist(lp)
 }
 
 
 
 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)
 }
 
 
 
 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)
 }
 
 
 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)
 }
 
 
 
 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)
 
 void
 freefunc(n)
-      union node *n;
-      {
-      if (n)
-           ckfree(n);
+       union node *n;
+{
+       if (n)
+               ckfree(n);
 }
 }
index a3b8218..56b9629 100644 (file)
@@ -6,7 +6,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"    @(#)sh.1        8.5 (Berkeley) %G%
+.\"    @(#)sh.1        8.6 (Berkeley) %G%
 .\"
 .na
 .TH SH 1
 .\"
 .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
 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''
 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
 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.
 eval string...
 Concatenate all the arguments with spaces.  Then
 re-parse and execute the command.