Merge in my changes from vangogh, and fix the x=false; echo $? == 0

bug.
This commit is contained in:
christos 1995-05-11 21:28:33 +00:00
parent 8aa6c376b6
commit 07bae7eddd
67 changed files with 1110 additions and 1152 deletions

View File

@ -1,21 +1,19 @@
# $NetBSD: Makefile,v 1.19 1995/03/21 09:08:36 cgd Exp $
# @(#)Makefile 8.1 (Berkeley) 6/8/93
# $NetBSD: Makefile,v 1.20 1995/05/11 21:28:33 christos Exp $
# @(#)Makefile 8.4 (Berkeley) 5/5/95
PROG= sh
SRCS= alias.c builtins.c cd.c echo.c error.c eval.c exec.c expand.c \
histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
mystring.c nodes.c options.c parser.c redir.c show.c \
syntax.c trap.c output.c ulimit.c var.c
mystring.c nodes.c options.c parser.c redir.c show.c syntax.c \
trap.c output.c var.c
OBJS+= init.o arith.o arith_lex.o
LDADD+= -ll -ledit -ltermcap
DPADD+= ${LIBL} ${LIBEDIT} ${LIBTERMCAP}
LFLAGS= -8 # 8-bit lex scanner for arithmetic
CFLAGS+=-DSHELL -I. -I${.CURDIR}
.PATH: ${.CURDIR}/bltin ${.CURDIR}/../../usr.bin/printf
CLEANFILES+=\
builtins.c builtins.h init.c mkinit mknodes mksyntax \
nodes.c nodes.h syntax.c syntax.h token.def \
y.tab.h
nodes.c nodes.h printf.o syntax.c syntax.h token.def y.tab.h
.depend parser.o: token.def
token.def: mktokens

View File

@ -1,4 +1,4 @@
# $NetBSD: TOUR,v 1.6 1995/03/21 09:08:38 cgd Exp $
# $NetBSD: TOUR,v 1.7 1995/05/11 21:28:38 christos Exp $
# @(#)TOUR 8.1 (Berkeley) 5/31/93
NOTE -- This is the original TOUR paper distributed with ash and

View File

@ -1,4 +1,4 @@
/* $NetBSD: alias.c,v 1.5 1995/03/21 09:08:40 cgd Exp $ */
/* $NetBSD: alias.c,v 1.6 1995/05/11 21:28:40 christos Exp $ */
/*-
* Copyright (c) 1993
@ -38,12 +38,13 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)alias.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: alias.c,v 1.5 1995/03/21 09:08:40 cgd Exp $";
static char rcsid[] = "$NetBSD: alias.c,v 1.6 1995/05/11 21:28:40 christos Exp $";
#endif
#endif /* not lint */
#include <stdlib.h>
#include "shell.h"
#include "input.h"
#include "output.h"
@ -57,6 +58,8 @@ static char rcsid[] = "$NetBSD: alias.c,v 1.5 1995/03/21 09:08:40 cgd Exp $";
struct alias *atab[ATABSIZE];
STATIC void setalias __P((char *, char *));
STATIC int unalias __P((char *));
STATIC struct alias **hashalias __P((char *));
STATIC
@ -215,7 +218,7 @@ aliascmd(argc, argv)
}
return (0);
}
while (n = *++argv) {
while ((n = *++argv) != NULL) {
if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */
if ((ap = lookupalias(n, 0)) == NULL) {
outfmt(out2, "alias: %s not found\n", n);

View File

@ -1,4 +1,4 @@
/* $NetBSD: alias.h,v 1.3 1995/03/21 09:08:41 cgd Exp $ */
/* $NetBSD: alias.h,v 1.4 1995/05/11 21:28:42 christos Exp $ */
/*-
* Copyright (c) 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)alias.h 8.1 (Berkeley) 5/31/93
* @(#)alias.h 8.2 (Berkeley) 5/4/95
*/
#define ALIASINUSE 1
@ -47,4 +47,7 @@ struct alias {
int flag;
};
struct alias *lookupalias();
struct alias *lookupalias __P((char *, int));
int aliascmd __P((int, char **));
int unaliascmd __P((int, char **));
void rmaliases __P((void));

39
bin/sh/arith.h Normal file
View File

@ -0,0 +1,39 @@
/* $NetBSD: arith.h,v 1.1 1995/05/11 21:28:44 christos Exp $ */
/*-
* Copyright (c) 1995
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)arith.h 1.1 (Berkeley) 5/4/95
*/
int arith __P((char *));
int expcmd __P((int , char **));

View File

@ -53,7 +53,7 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
| ARITH_NUM
;
%%
/* $NetBSD: arith.y,v 1.5 1995/03/21 09:08:43 cgd Exp $ */
/* $NetBSD: arith.y,v 1.6 1995/05/11 21:28:45 christos Exp $ */
/*-
* Copyright (c) 1993
@ -93,9 +93,9 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
#ifndef lint
#if 0
static char sccsid[] = "@(#)arith.y 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: arith.y,v 1.5 1995/03/21 09:08:43 cgd Exp $";
static char sccsid[] = "$NetBSD: arith.y,v 1.6 1995/05/11 21:28:45 christos Exp $";
#endif
#endif /* not lint */
@ -106,6 +106,7 @@ static char rcsid[] = "$NetBSD: arith.y,v 1.5 1995/03/21 09:08:43 cgd Exp $";
char *arith_buf, *arith_startbuf;
int
arith(s)
char *s;
{
@ -121,6 +122,7 @@ arith(s)
return (result);
}
void
yyerror(s)
char *s;
{
@ -134,7 +136,9 @@ yyerror(s)
/*
* The exp(1) builtin.
*/
int
expcmd(argc, argv)
int argc;
char **argv;
{
char *p;

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: arith_lex.l,v 1.4 1995/03/21 09:08:45 cgd Exp $ */
/* $NetBSD: arith_lex.l,v 1.5 1995/05/11 21:28:46 christos Exp $ */
/*-
* Copyright (c) 1993
@ -39,13 +39,15 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)arith_lex.l 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: arith_lex.l,v 1.4 1995/03/21 09:08:45 cgd Exp $";
static char sccsid[] = "$NetBSD: arith_lex.l,v 1.5 1995/05/11 21:28:46 christos Exp $";
#endif
#endif /* not lint */
#include <unistd.h>
#include "y.tab.h"
#include "error.h"
extern yylval;
extern char *arith_buf, *arith_startbuf;
@ -82,6 +84,7 @@ extern char *arith_buf, *arith_startbuf;
. { error("arith: syntax error: \"%s\"\n", arith_startbuf); }
%%
void
arith_lex_reset() {
YY_NEW_FILE;
}

View File

@ -1,5 +1,5 @@
#!/bin/sh -
# $NetBSD: builtins.def,v 1.11 1995/03/21 09:08:47 cgd Exp $
# $NetBSD: builtins.def,v 1.12 1995/05/11 21:28:48 christos Exp $
#
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
@ -35,7 +35,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)builtins 8.1 (Berkeley) 5/31/93
# @(#)builtins.def 8.4 (Berkeley) 5/4/95
#
# This file lists all the builtin commands. The first column is the name
@ -47,10 +47,6 @@
# for bltincmd, which is run when the user does not specify a command, must
# come first.
#
# Copyright (C) 1989 by Kenneth Almquist. All rights reserved.
# This file is part of ash, which is distributed under the terms specified
# by the Ash General Public License. See the file named LICENSE.
#
# NOTE: bltincmd must come first!
bltincmd command

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.12 1995/03/21 09:08:48 cgd Exp $ */
/* $NetBSD: cd.c,v 1.13 1995/05/11 21:28:49 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,14 +38,15 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)cd.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: cd.c,v 1.12 1995/03/21 09:08:48 cgd Exp $";
static char rcsid[] = "$NetBSD: cd.c,v 1.13 1995/05/11 21:28:49 christos Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
@ -61,22 +62,14 @@ static char rcsid[] = "$NetBSD: cd.c,v 1.12 1995/03/21 09:08:48 cgd Exp $";
#include "output.h"
#include "memalloc.h"
#include "error.h"
#include "redir.h"
#include "mystring.h"
#include "extern.h"
#ifdef __STDC__
STATIC int docd(char *, int);
STATIC void updatepwd(char *);
STATIC void getpwd(void);
STATIC char *getcomponent(void);
#else
STATIC int docd();
STATIC void updatepwd();
STATIC void getpwd();
STATIC char *getcomponent();
#endif
#include "show.h"
STATIC int docd __P((char *, int));
STATIC char *getcomponent __P((void));
STATIC void updatepwd __P((char *));
STATIC void getpwd __P((void));
char *curdir; /* current working directory */
char *prevdir; /* previous working directory */
@ -119,6 +112,8 @@ cdcmd(argc, argv)
}
}
error("can't cd to %s", dest);
/*NOTREACHED*/
return 0;
}
@ -177,7 +172,7 @@ top:
}
first = 1;
while ((q = getcomponent()) != NULL) {
if (q[0] == '\0' || q[0] == '.' && q[1] == '\0')
if (q[0] == '\0' || (q[0] == '.' && q[1] == '\0'))
continue;
if (! first)
STPUTC('/', p);
@ -370,7 +365,7 @@ getpwd() {
pip[1] = -1;
p = buf;
while ((i = read(pip[0], p, buf + MAXPWD - p)) > 0
|| i == -1 && errno == EINTR) {
|| (i == -1 && errno == EINTR)) {
if (i > 0)
p += i;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: error.c,v 1.13 1995/03/23 00:01:03 mycroft Exp $ */
/* $NetBSD: error.c,v 1.14 1995/05/11 21:28:51 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint
#if 0
char sccsid[] = "@(#)error.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: error.c,v 1.13 1995/03/23 00:01:03 mycroft Exp $";
static char rcsid[] = "$NetBSD: error.c,v 1.14 1995/05/11 21:28:51 christos Exp $";
#endif
#endif /* not lint */
@ -53,12 +53,8 @@ static char rcsid[] = "$NetBSD: error.c,v 1.13 1995/03/23 00:01:03 mycroft Exp $
#include "options.h"
#include "output.h"
#include "error.h"
#include "show.h"
#include <signal.h>
#ifdef __STDC__
#include "stdarg.h"
#else
#include <varargs.h>
#endif
#include <unistd.h>
#include <errno.h>
@ -134,21 +130,23 @@ error2(a, b)
* formatting. It then raises the error exception.
*/
#ifdef __STDC__
#if __STDC__
void
error(char *msg, ...) {
error(char *msg, ...)
#else
void
error(va_alist)
va_dcl
{
#endif
{
#if !__STDC__
char *msg;
#endif
va_list ap;
CLEAR_PENDING_INT;
INTOFF;
#ifdef __STDC__
#if __STDC__
va_start(ap, msg);
#else
va_start(ap);
@ -187,55 +185,57 @@ struct errname {
#define ALL (E_OPEN|E_CREAT|E_EXEC)
STATIC const struct errname errormsg[] = {
EINTR, ALL, "interrupted",
EACCES, ALL, "permission denied",
EIO, ALL, "I/O error",
ENOENT, E_OPEN, "no such file",
ENOENT, E_CREAT, "directory nonexistent",
ENOENT, E_EXEC, "not found",
ENOTDIR, E_OPEN, "no such file",
ENOTDIR, E_CREAT, "directory nonexistent",
ENOTDIR, E_EXEC, "not found",
EISDIR, ALL, "is a directory",
/* EMFILE, ALL, "too many open files", */
ENFILE, ALL, "file table overflow",
ENOSPC, ALL, "file system full",
{ EINTR, ALL, "interrupted" },
{ EACCES, ALL, "permission denied" },
{ EIO, ALL, "I/O error" },
{ ENOENT, E_OPEN, "no such file" },
{ ENOENT, E_CREAT,"directory nonexistent" },
{ ENOENT, E_EXEC, "not found" },
{ ENOTDIR, E_OPEN, "no such file" },
{ ENOTDIR, E_CREAT,"directory nonexistent" },
{ ENOTDIR, E_EXEC, "not found" },
{ EISDIR, ALL, "is a directory" },
#ifdef notdef
{ EMFILE, ALL, "too many open files" },
#endif
{ ENFILE, ALL, "file table overflow" },
{ ENOSPC, ALL, "file system full" },
#ifdef EDQUOT
EDQUOT, ALL, "disk quota exceeded",
{ EDQUOT, ALL, "disk quota exceeded" },
#endif
#ifdef ENOSR
ENOSR, ALL, "no streams resources",
{ ENOSR, ALL, "no streams resources" },
#endif
ENXIO, ALL, "no such device or address",
EROFS, ALL, "read-only file system",
ETXTBSY, ALL, "text busy",
{ ENXIO, ALL, "no such device or address" },
{ EROFS, ALL, "read-only file system" },
{ ETXTBSY, ALL, "text busy" },
#ifdef SYSV
EAGAIN, E_EXEC, "not enough memory",
{ EAGAIN, E_EXEC, "not enough memory" },
#endif
ENOMEM, ALL, "not enough memory",
{ ENOMEM, ALL, "not enough memory" },
#ifdef ENOLINK
ENOLINK, ALL, "remote access failed",
{ ENOLINK, ALL, "remote access failed" },
#endif
#ifdef EMULTIHOP
EMULTIHOP, ALL, "remote access failed",
{ EMULTIHOP, ALL, "remote access failed" },
#endif
#ifdef ECOMM
ECOMM, ALL, "remote access failed",
{ ECOMM, ALL, "remote access failed" },
#endif
#ifdef ESTALE
ESTALE, ALL, "remote access failed",
{ ESTALE, ALL, "remote access failed" },
#endif
#ifdef ETIMEDOUT
ETIMEDOUT, ALL, "remote access failed",
{ ETIMEDOUT, ALL, "remote access failed" },
#endif
#ifdef ELOOP
ELOOP, ALL, "symbolic link loop",
{ ELOOP, ALL, "symbolic link loop" },
#endif
E2BIG, E_EXEC, "argument list too long",
{ E2BIG, E_EXEC, "argument list too long" },
#ifdef ELIBACC
ELIBACC, E_EXEC, "shared library missing",
{ ELIBACC, E_EXEC, "shared library missing" },
#endif
0, 0, NULL
{ 0, 0, NULL },
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: error.h,v 1.7 1995/03/21 09:08:52 cgd Exp $ */
/* $NetBSD: error.h,v 1.8 1995/05/11 21:28:53 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)error.h 8.1 (Berkeley) 5/31/93
* @(#)error.h 8.2 (Berkeley) 5/4/95
*/
/*
@ -84,24 +84,16 @@ extern volatile int intpending;
extern char *commandname; /* name of command--printed on error */
#define INTOFF suppressint++
#define INTON if (--suppressint == 0 && intpending) onint(); else
#define INTON { if (--suppressint == 0 && intpending) onint(); }
#define FORCEINTON {suppressint = 0; if (intpending) onint();}
#define CLEAR_PENDING_INT intpending = 0
#define int_pending() intpending
#ifdef __STDC__
void exraise(int);
void onint(void);
void error2(char *, char *);
void error(char *, ...);
char *errmsg(int, int);
#else
void exraise();
void onint();
void error2();
void error();
char *errmsg();
#endif
void exraise __P((int));
void onint __P((void));
void error2 __P((char *, char *));
void error __P((char *, ...));
char *errmsg __P((int, int));
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.20 1995/03/31 21:58:09 christos Exp $ */
/* $NetBSD: eval.c,v 1.21 1995/05/11 21:28:56 christos Exp $ */
/*-
* Copyright (c) 1993
@ -38,12 +38,15 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)eval.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)eval.c 8.4 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: eval.c,v 1.20 1995/03/31 21:58:09 christos Exp $";
static char rcsid[] = "$NetBSD: eval.c,v 1.21 1995/05/11 21:28:56 christos Exp $";
#endif
#endif /* not lint */
#include <signal.h>
#include <unistd.h>
/*
* Evaluate a command.
*/
@ -65,13 +68,11 @@ static char rcsid[] = "$NetBSD: eval.c,v 1.20 1995/03/31 21:58:09 christos Exp $
#include "var.h"
#include "memalloc.h"
#include "error.h"
#include "show.h"
#include "mystring.h"
#ifndef NO_HISTORY
#include "myhistedit.h"
#endif
#include "extern.h"
#include <signal.h>
#include <unistd.h>
/* flags in argument to evaltree */
@ -96,26 +97,14 @@ struct strlist *cmdenviron;
int exitstatus; /* exit status of last command */
#ifdef __STDC__
STATIC void evalloop(union node *);
STATIC void evalfor(union node *);
STATIC void evalcase(union node *, int);
STATIC void evalsubshell(union node *, int);
STATIC void expredir(union node *);
STATIC void evalpipe(union node *);
STATIC void evalcommand(union node *, int, struct backcmd *);
STATIC void prehash(union node *);
#else
STATIC void evalloop();
STATIC void evalfor();
STATIC void evalcase();
STATIC void evalsubshell();
STATIC void expredir();
STATIC void evalpipe();
STATIC void evalcommand();
STATIC void prehash();
#endif
STATIC void evalloop __P((union node *));
STATIC void evalfor __P((union node *));
STATIC void evalcase __P((union node *, int));
STATIC void evalsubshell __P((union node *, int));
STATIC void expredir __P((union node *));
STATIC void evalpipe __P((union node *));
STATIC void evalcommand __P((union node *, int, struct backcmd *));
STATIC void prehash __P((union node *));
/*
@ -615,6 +604,13 @@ evalcommand(cmd, flags, backcmd)
struct localvar *volatile savelocalvars;
volatile int e;
char *lastarg;
#if __GNUC__
/* Avoid longjmp clobbering */
(void) &argv;
(void) &argc;
(void) &lastarg;
(void) &flags;
#endif
/* First expand the arguments. */
TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@ -700,11 +696,11 @@ evalcommand(cmd, flags, backcmd)
/* Fork off a child process if necessary. */
if (cmd->ncmd.backgnd
|| cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0
|| (flags & EV_BACKCMD) != 0
|| (cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0)
|| ((flags & EV_BACKCMD) != 0
&& (cmdentry.cmdtype != CMDBUILTIN
|| cmdentry.u.index == DOTCMD
|| cmdentry.u.index == EVALCMD)) {
|| cmdentry.u.index == EVALCMD))) {
jp = makejob(cmd, 1);
mode = cmd->ncmd.backgnd;
if (flags & EV_BACKCMD) {
@ -894,7 +890,8 @@ bltincmd(argc, argv)
char **argv;
{
listsetvar(cmdenviron);
return 0;
/* Preserve the exitstatus as POSIX.2 mandates */
return exitstatus;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.h,v 1.7 1995/03/21 09:08:57 cgd Exp $ */
/* $NetBSD: eval.h,v 1.8 1995/05/11 21:28:58 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)eval.h 8.1 (Berkeley) 5/31/93
* @(#)eval.h 8.2 (Berkeley) 5/4/95
*/
extern char *commandname; /* currently executing command */
@ -50,17 +50,17 @@ struct backcmd { /* result of evalbackcmd */
struct job *jp; /* job structure for command */
};
#ifdef __STDC__
void evalstring(char *);
int evalcmd __P((int, char **));
void evalstring __P((char *));
union node; /* BLETCH for ansi C */
void evaltree(union node *, int);
void evalbackcmd(union node *, struct backcmd *);
#else
void evalstring();
void evaltree();
void evalbackcmd();
#endif
void evaltree __P((union node *, int));
void evalbackcmd __P((union node *, struct backcmd *));
int bltincmd __P((int, char **));
int breakcmd __P((int, char **));
int returncmd __P((int, char **));
int falsecmd __P((int, char **));
int truecmd __P((int, char **));
int execcmd __P((int, char **));
/* in_function returns nonzero if we are currently evaluating a function */
#define in_function() funcnest

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.15 1995/03/21 09:08:59 cgd Exp $ */
/* $NetBSD: exec.c,v 1.16 1995/05/11 21:29:02 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,12 +38,19 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)exec.c 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: exec.c,v 1.15 1995/03/21 09:08:59 cgd Exp $";
static char rcsid[] = "$NetBSD: exec.c,v 1.16 1995/05/11 21:29:02 christos Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
/*
* When commands are first encountered, they are entered in a hash table.
* This ensures that a full path search will not have to be done for them
@ -70,12 +77,8 @@ static char rcsid[] = "$NetBSD: exec.c,v 1.15 1995/03/21 09:08:59 cgd Exp $";
#include "error.h"
#include "init.h"
#include "mystring.h"
#include "show.h"
#include "jobs.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#define CMDTABLESIZE 31 /* should be prime */
@ -96,21 +99,12 @@ STATIC struct tblentry *cmdtable[CMDTABLESIZE];
STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */
#ifdef __STDC__
STATIC void tryexec(char *, char **, char **);
STATIC void execinterp(char **, char **);
STATIC void printentry(struct tblentry *, int);
STATIC void clearcmdentry(int);
STATIC struct tblentry *cmdlookup(char *, int);
STATIC void delete_cmd_entry(void);
#else
STATIC void tryexec();
STATIC void execinterp();
STATIC void printentry();
STATIC void clearcmdentry();
STATIC struct tblentry *cmdlookup();
STATIC void delete_cmd_entry();
#endif
STATIC void tryexec __P((char *, char **, char **));
STATIC void execinterp __P((char **, char **));
STATIC void printentry __P((struct tblentry *, int));
STATIC void clearcmdentry __P((int));
STATIC struct tblentry *cmdlookup __P((char *, int));
STATIC void delete_cmd_entry __P((void));
@ -153,7 +147,9 @@ tryexec(cmd, argv, envp)
char **envp;
{
int e;
#ifndef BSD
char *p;
#endif
#ifdef SYSV
do {
@ -345,7 +341,7 @@ hashcmd(argc, argv)
while ((name = *argptr) != NULL) {
if ((cmdp = cmdlookup(name, 0)) != NULL
&& (cmdp->cmdtype == CMDNORMAL
|| cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))
|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
delete_cmd_entry();
find_command(name, &entry, 1);
if (verbose) {
@ -571,7 +567,7 @@ hashcd() {
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
if (cmdp->cmdtype == CMDNORMAL
|| cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)
|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))
cmdp->rehash = 1;
}
}
@ -602,8 +598,8 @@ changepath(newval)
for (;;) {
if (*old != *new) {
firstchange = index;
if (*old == '\0' && *new == ':'
|| *old == ':' && *new == '\0')
if ((*old == '\0' && *new == ':')
|| (*old == ':' && *new == '\0'))
firstchange++;
old = new; /* ignore subsequent differences */
}
@ -612,8 +608,6 @@ changepath(newval)
if (*new == '%' && bltin < 0 && prefix("builtin", new + 1))
bltin = index;
if (*new == ':') {
char c = *(new+1);
index++;
}
new++, old++;
@ -644,8 +638,10 @@ clearcmdentry(firstchange)
for (tblp = cmdtable ; tblp < &cmdtable[CMDTABLESIZE] ; tblp++) {
pp = tblp;
while ((cmdp = *pp) != NULL) {
if (cmdp->cmdtype == CMDNORMAL && cmdp->param.index >= firstchange
|| cmdp->cmdtype == CMDBUILTIN && builtinloc >= firstchange) {
if ((cmdp->cmdtype == CMDNORMAL &&
cmdp->param.index >= firstchange)
|| (cmdp->cmdtype == CMDBUILTIN &&
builtinloc >= firstchange)) {
*pp = cmdp->next;
ckfree(cmdp);
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.h,v 1.7 1995/03/21 09:09:02 cgd Exp $ */
/* $NetBSD: exec.h,v 1.8 1995/05/11 21:29:05 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)exec.h 8.1 (Berkeley) 5/31/93
* @(#)exec.h 8.2 (Berkeley) 5/4/95
*/
/* values of cmdtype */
@ -56,22 +56,15 @@ struct cmdentry {
extern char *pathopt; /* set by padvance */
#ifdef __STDC__
void shellexec(char **, char **, char *, int);
char *padvance(char **, char *);
void find_command(char *, struct cmdentry *, int);
int find_builtin(char *);
void hashcd(void);
void changepath(char *);
void defun(char *, union node *);
int unsetfunc(char *);
#else
void shellexec();
char *padvance();
void find_command();
int find_builtin();
void hashcd();
void changepath();
void defun();
int unsetfunc();
#endif
void shellexec __P((char **, char **, char *, int));
char *padvance __P((char **, char *));
int hashcmd __P((int, char **));
void find_command __P((char *, struct cmdentry *, int));
int find_builtin __P((char *));
void hashcd __P((void));
void changepath __P((char *));
void deletefuncs __P((void));
void getcmdentry __P((char *, struct cmdentry *));
void addcmdentry __P((char *, struct cmdentry *));
void defun __P((char *, union node *));
int unsetfunc __P((char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.c,v 1.17 1995/03/21 09:09:04 cgd Exp $ */
/* $NetBSD: expand.c,v 1.18 1995/05/11 21:29:06 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,12 +38,21 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)expand.c 8.2 (Berkeley) 10/22/93";
static char sccsid[] = "@(#)expand.c 8.4 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: expand.c,v 1.17 1995/03/21 09:09:04 cgd Exp $";
static char rcsid[] = "$NetBSD: expand.c,v 1.18 1995/05/11 21:29:06 christos Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <pwd.h>
#include <stdlib.h>
/*
* Routines to expand arguments to commands. We have to deal with
* backquotes, shell variables, and file metacharacters.
@ -64,13 +73,8 @@ static char rcsid[] = "$NetBSD: expand.c,v 1.17 1995/03/21 09:09:04 cgd Exp $";
#include "memalloc.h"
#include "error.h"
#include "mystring.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <pwd.h>
#include "arith.h"
#include "show.h"
/*
* Structure specifying which parts of the string should be searched
@ -91,43 +95,22 @@ struct ifsregion ifsfirst; /* first struct in list of ifs regions */
struct ifsregion *ifslastp; /* last struct in list */
struct arglist exparg; /* holds expanded arg list */
#ifdef __STDC__
STATIC void argstr(char *, int);
STATIC void expbackq(union node *, int, int);
STATIC int subevalvar(char *, char *, int, int, int);
STATIC char *evalvar(char *, int);
STATIC int varisset(int);
STATIC void varvalue(int, int, int);
STATIC void recordregion(int, int, int);
STATIC void ifsbreakup(char *, struct arglist *);
STATIC void expandmeta(struct strlist *, int);
STATIC void expmeta(char *, char *);
STATIC void expari(int);
STATIC void addfname(char *);
STATIC struct strlist *expsort(struct strlist *);
STATIC struct strlist *msort(struct strlist *, int);
STATIC int pmatch(char *, char *);
STATIC char *exptilde(char *, int);
STATIC char *cvtnum(int, char *);
#else
STATIC void argstr();
STATIC void expbackq();
STATIC int subevalvar();
STATIC char *evalvar();
STATIC int varisset();
STATIC void varvalue();
STATIC void recordregion();
STATIC void ifsbreakup();
STATIC void expandmeta();
STATIC void expmeta();
STATIC void expari();
STATIC void addfname();
STATIC struct strlist *expsort();
STATIC struct strlist *msort();
STATIC int pmatch();
STATIC char *exptilde();
STATIC char *cvtnum();
#endif
STATIC void argstr __P((char *, int));
STATIC char *exptilde __P((char *, int));
STATIC void expbackq __P((union node *, int, int));
STATIC int subevalvar __P((char *, char *, int, int, int));
STATIC char *evalvar __P((char *, int));
STATIC int varisset __P((int));
STATIC void varvalue __P((int, int, int));
STATIC void recordregion __P((int, int, int));
STATIC void ifsbreakup __P((char *, struct arglist *));
STATIC void expandmeta __P((struct strlist *, int));
STATIC void expmeta __P((char *, char *));
STATIC void addfname __P((char *));
STATIC struct strlist *expsort __P((struct strlist *));
STATIC struct strlist *msort __P((struct strlist *, int));
STATIC int pmatch __P((char *, char *));
STATIC char *cvtnum __P((int, char *));
/*
* Expand shell variables and backquotes inside a here document.
@ -277,7 +260,7 @@ exptilde(p, flag)
char *home;
int quotes = flag & (EXP_FULL | EXP_CASE);
while (c = *p) {
while ((c = *p) != '\0') {
switch(c) {
case CTLESC:
return (startp);
@ -303,7 +286,7 @@ done:
if (*home == '\0')
goto lose;
*p = c;
while (c = *home++) {
while ((c = *home++) != '\0') {
if (quotes && SQSYNTAX[c] == CCTL)
STPUTC(CTLESC, expdest);
STPUTC(c, expdest);
@ -571,7 +554,7 @@ again: /* jump here after setting a variable with ${var=text} */
val = NULL;
} else {
val = lookupvar(var);
if (val == NULL || (varflags & VSNUL) && val[0] == '\0') {
if (val == NULL || ((varflags & VSNUL) && val[0] == '\0')) {
val = NULL;
set = 0;
} else
@ -1055,7 +1038,7 @@ expmeta(enddir, name)
*endname++ = '\0';
}
matchdot = 0;
if (start[0] == '.' || start[0] == CTLESC && start[1] == '.')
if (start[0] == '.' || (start[0] == CTLESC && start[1] == '.'))
matchdot++;
while (! int_pending() && (dp = readdir(dirp)) != NULL) {
if (dp->d_name[0] == '.' && ! matchdot)
@ -1066,7 +1049,9 @@ expmeta(enddir, name)
addfname(expdir);
} else {
char *q;
for (p = enddir, q = dp->d_name ; *p++ = *q++ ;);
for (p = enddir, q = dp->d_name;
(*p++ = *q++) != '\0';)
continue;
p[-1] = '/';
expmeta(p, endname);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.h,v 1.7 1995/03/21 09:09:06 cgd Exp $ */
/* $NetBSD: expand.h,v 1.8 1995/05/11 21:29:08 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)expand.h 8.1 (Berkeley) 5/31/93
* @(#)expand.h 8.2 (Berkeley) 5/4/95
*/
struct strlist {
@ -59,17 +59,10 @@ struct arglist {
#define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */
#ifdef __STDC__
union node;
void expandarg(union node *, struct arglist *, int);
void expandhere(union node *, int);
int patmatch(char *, char *);
void rmescapes(char *);
int casematch(union node *, char *);
#else
void expandarg();
void expandhere();
int patmatch();
void rmescapes();
int casematch();
#endif
void expandhere __P((union node *, int));
void expandarg __P((union node *, struct arglist *, int));
void expari __P((int));
int patmatch __P((char *, char *));
void rmescapes __P((char *));
int casematch __P((union node *, char *));

View File

@ -1,36 +0,0 @@
/* $NetBSD: extern.h,v 1.3 1995/03/21 09:09:08 cgd Exp $ */
/*
* Copyright (c) 1994 James A. Jegers
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
int copyfd __P((int, int));
int fd0_redirected_p();
void histedit();
void opentrace();
void optschanged();
void sethistsize();
void readcmdfile __P((char *));
void trargs __P((char **));
void trputs __P((char *));

View File

@ -1,5 +1,4 @@
# $NetBSD: cmv,v 1.6 1995/03/21 09:10:52 cgd Exp $
#
# $NetBSD: cmv,v 1.7 1995/05/11 21:31:05 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)cmv 8.1 (Berkeley) 5/31/93
# @(#)cmv 8.2 (Berkeley) 5/4/95
# Conditional move--don't replace an existing file.

View File

@ -1,5 +1,4 @@
# $NetBSD: dirs,v 1.6 1995/03/21 09:10:54 cgd Exp $
#
# $NetBSD: dirs,v 1.7 1995/05/11 21:31:08 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)dirs 8.1 (Berkeley) 5/31/93
# @(#)dirs 8.2 (Berkeley) 5/4/95
# pushd, popd, and dirs --- written by Chris Bertin
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris

View File

@ -1,5 +1,4 @@
# $NetBSD: kill,v 1.6 1995/03/21 09:10:57 cgd Exp $
#
# $NetBSD: kill,v 1.7 1995/05/11 21:31:10 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)kill 8.1 (Berkeley) 5/31/93
# @(#)kill 8.2 (Berkeley) 5/4/95
# Convert job names to process ids and then run /bin/kill.

View File

@ -1,5 +1,4 @@
# $NetBSD: login,v 1.6 1995/03/21 09:10:59 cgd Exp $
#
# $NetBSD: login,v 1.7 1995/05/11 21:31:11 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)login 8.1 (Berkeley) 5/31/93
# @(#)login 8.2 (Berkeley) 5/4/95
# replaces the login builtin in the BSD shell
login () exec login "$@"

View File

@ -1,5 +1,4 @@
# $NetBSD: newgrp,v 1.6 1995/03/21 09:11:01 cgd Exp $
#
# $NetBSD: newgrp,v 1.7 1995/05/11 21:31:12 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,6 +33,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)newgrp 8.1 (Berkeley) 5/31/93
# @(#)newgrp 8.2 (Berkeley) 5/4/95
newgrp() exec newgrp "$@"

View File

@ -1,5 +1,4 @@
# $NetBSD: popd,v 1.6 1995/03/21 09:11:03 cgd Exp $
#
# $NetBSD: popd,v 1.7 1995/05/11 21:31:13 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)popd 8.1 (Berkeley) 5/31/93
# @(#)popd 8.2 (Berkeley) 5/4/95
# pushd, popd, and dirs --- written by Chris Bertin
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris

View File

@ -1,5 +1,4 @@
# $NetBSD: pushd,v 1.6 1995/03/21 09:11:04 cgd Exp $
#
# $NetBSD: pushd,v 1.7 1995/05/11 21:31:15 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)pushd 8.1 (Berkeley) 5/31/93
# @(#)pushd 8.2 (Berkeley) 5/4/95
# pushd, popd, and dirs --- written by Chris Bertin
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris

View File

@ -1,5 +1,4 @@
# $NetBSD: suspend,v 1.6 1995/03/21 09:11:05 cgd Exp $
#
# $NetBSD: suspend,v 1.7 1995/05/11 21:31:17 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)suspend 8.1 (Berkeley) 5/31/93
# @(#)suspend 8.2 (Berkeley) 5/4/95
suspend() {
local -

View File

@ -1,4 +1,4 @@
/* $NetBSD: histedit.c,v 1.7 1995/03/31 21:58:13 christos Exp $ */
/* $NetBSD: histedit.c,v 1.8 1995/05/11 21:29:12 christos Exp $ */
/*-
* Copyright (c) 1993
@ -38,31 +38,33 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)histedit.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: histedit.c,v 1.7 1995/03/31 21:58:13 christos Exp $";
static char rcsid[] = "$NetBSD: histedit.c,v 1.8 1995/05/11 21:29:12 christos Exp $";
#endif
#endif /* not lint */
/*
* Editline and history functions (and glue).
*/
#include <sys/param.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
* Editline and history functions (and glue).
*/
#include "shell.h"
#include "parser.h"
#include "var.h"
#include "options.h"
#include "main.h"
#include "output.h"
#include "mystring.h"
#ifndef NO_HISTORY
#include "myhistedit.h"
#endif
#include "error.h"
#include "eval.h"
#include "histedit.h"
#include "memalloc.h"
#include "extern.h"
#define MAXHISTLOOPS 4 /* max recursions through fc */
#define DEFEDITOR "ed" /* default editor *should* be $EDITOR */
@ -73,8 +75,6 @@ int displayhist;
static FILE *el_in, *el_out;
STATIC char *fc_replace __P((const char *, char *, char *));
int not_fcnumber __P((char *));
int str_to_event __P((char *, int));
/*
* Set history and editing status. Called whenever the status may
@ -149,7 +149,8 @@ bad:
void
sethistsize() {
sethistsize()
{
char *cp;
int histsize;
@ -169,7 +170,7 @@ sethistsize() {
int
histcmd(argc, argv)
int argc;
char *argv[];
char **argv;
{
extern char *optarg;
extern int optind, optopt, optreset;
@ -186,6 +187,21 @@ histcmd(argc, argv)
struct jmploc *volatile savehandler;
char editfile[MAXPATHLEN + 1];
FILE *efp;
#ifdef __GNUC__
/* Avoid longjmp clobbering */
(void) &editor;
(void) &lflg;
(void) &nflg;
(void) &rflg;
(void) &sflg;
(void) &firststr;
(void) &laststr;
(void) &pat;
(void) &repl;
(void) &efp;
(void) &argc;
(void) &argv;
#endif
if (hist == NULL)
error("history not active");
@ -377,6 +393,7 @@ histcmd(argc, argv)
--active;
if (displayhist)
displayhist = 0;
return 0;
}
STATIC char *

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.h,v 1.7 1995/03/21 09:09:11 cgd Exp $ */
/* $NetBSD: init.h,v 1.8 1995/05/11 21:29:14 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,15 +35,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)init.h 8.1 (Berkeley) 5/31/93
* @(#)init.h 8.2 (Berkeley) 5/4/95
*/
#ifdef __STDC__
void init(void);
void reset(void);
void initshellproc(void);
#else
void init();
void reset();
void initshellproc();
#endif
void init __P((void));
void reset __P((void));
void initshellproc __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.c,v 1.13 1995/03/21 09:09:13 cgd Exp $ */
/* $NetBSD: input.c,v 1.14 1995/05/11 21:29:15 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,22 +38,24 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)input.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: input.c,v 1.13 1995/03/21 09:09:13 cgd Exp $";
static char rcsid[] = "$NetBSD: input.c,v 1.14 1995/05/11 21:29:15 christos Exp $";
#endif
#endif /* not lint */
#include <stdio.h> /* defines BUFSIZ */
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
/*
* This file implements the input routines used by the parser.
*/
#include <stdio.h> /* defines BUFSIZ */
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include "shell.h"
#include "redir.h"
#include "syntax.h"
#include "input.h"
#include "output.h"
@ -62,10 +64,7 @@ static char rcsid[] = "$NetBSD: input.c,v 1.13 1995/03/21 09:09:13 cgd Exp $";
#include "error.h"
#include "alias.h"
#include "parser.h"
#include "extern.h"
#ifndef NO_HISTORY
#include "myhistedit.h"
#endif
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
@ -106,19 +105,9 @@ int pushednleft; /* copy of parsenleft when text pushed back */
int init_editline = 0; /* editline library initialized? */
int whichprompt; /* 1 == PS1, 2 == PS2 */
#ifndef NO_HISTORY
EditLine *el; /* cookie for editline package */
#endif
#ifdef __STDC__
STATIC void pushfile(void);
#else
STATIC void pushfile();
#endif
void popstring();
STATIC void pushfile __P((void));
#ifdef mkinit
INCLUDE "input.h"
@ -198,9 +187,7 @@ preadbuffer() {
register char *p, *q;
register int i;
register int something;
#ifndef NO_HISTORY
extern EditLine *el;
#endif
if (parsefile->strpush) {
popstring();
@ -213,7 +200,6 @@ preadbuffer() {
flushout(&errout);
retry:
p = parsenextc = parsefile->buf;
#ifndef NO_HISTORY
if (parsefile->fd == 0 && el) {
const char *rl_cp;
int len;
@ -227,12 +213,8 @@ retry:
i = len;
} else {
#endif
regular_read:
i = read(parsefile->fd, p, BUFSIZ - 1);
#ifndef NO_HISTORY
}
#endif
eof:
if (i <= 0) {
if (i < 0) {
@ -282,14 +264,12 @@ eof:
parsenleft = q - parsefile->buf - 1;
done:
#ifndef NO_HISTORY
if (parsefile->fd == 0 && hist && something) {
INTOFF;
history(hist, whichprompt == 1 ? H_ENTER : H_ADD,
parsefile->buf);
INTON;
}
#endif
if (vflag) {
/*
* This isn't right. Most shells coordinate it with
@ -398,8 +378,7 @@ setinputfile(fname, push)
void
setinputfd(fd, push)
int fd;
int push;
int fd, push;
{
if (push) {
pushfile();
@ -423,7 +402,7 @@ void
setinputstring(string, push)
char *string;
int push;
{
{
INTOFF;
if (push)
pushfile();

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.h,v 1.7 1995/03/21 09:09:15 cgd Exp $ */
/* $NetBSD: input.h,v 1.8 1995/05/11 21:29:16 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)input.h 8.1 (Berkeley) 5/31/93
* @(#)input.h 8.2 (Berkeley) 5/4/95
*/
/* PEOF (the end of file marker) is defined in syntax.h */
@ -50,31 +50,17 @@ extern int parsenleft; /* number of characters left in input buffer */
extern char *parsenextc; /* next character in input buffer */
extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */
#ifdef __STDC__
char *pfgets(char *, int);
int pgetc(void);
int preadbuffer(void);
void pungetc(void);
void pushstring(char *, int, void *);
void setinputfile(char *, int);
void setinputfd(int, int);
void setinputstring(char *, int);
void popfile(void);
void popallfiles(void);
void closescript(void);
#else
char *pfgets();
int pgetc();
int preadbuffer();
void pungetc();
void setinputfile();
void setinputfd();
void setinputstring();
void popfile();
void popallfiles();
void pushstring();
void closescript();
#endif
char *pfgets __P((char *, int));
int pgetc __P((void));
int preadbuffer __P((void));
void pungetc __P((void));
void pushstring __P((char *, int, void *));
void popstring __P((void));
void setinputfile __P((char *, int));
void setinputfd __P((int, int));
void setinputstring __P((char *, int));
void popfile __P((void));
void popallfiles __P((void));
void closescript __P((void));
#define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer())

View File

@ -1,4 +1,4 @@
/* $NetBSD: jobs.c,v 1.15 1995/03/21 09:09:17 cgd Exp $ */
/* $NetBSD: jobs.c,v 1.16 1995/05/11 21:29:18 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,17 +38,32 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)jobs.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: jobs.c,v 1.15 1995/03/21 09:09:17 cgd Exp $";
static char rcsid[] = "$NetBSD: jobs.c,v 1.16 1995/05/11 21:29:18 christos Exp $";
#endif
#endif /* not lint */
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/param.h>
#ifdef BSD
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include "shell.h"
#if JOBS
#include "sgtty.h"
#undef CEOF /* syntax.h redefines this */
#endif
#include "redir.h"
#include "show.h"
#include "main.h"
#include "parser.h"
#include "nodes.h"
@ -61,18 +76,6 @@ static char rcsid[] = "$NetBSD: jobs.c,v 1.15 1995/03/21 09:09:17 cgd Exp $";
#include "memalloc.h"
#include "error.h"
#include "mystring.h"
#include "extern.h"
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#ifdef BSD
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif
struct job *jobtab; /* array of jobs */
@ -83,22 +86,14 @@ int initialpgrp; /* pgrp of shell on invocation */
short curjob; /* current job */
#endif
#ifdef __STDC__
STATIC void restartjob(struct job *);
STATIC struct job *getjob(char *);
STATIC void freejob(struct job *);
STATIC int procrunning(int);
STATIC int dowait(int, struct job *);
STATIC int waitproc(int, int *);
#else
STATIC void restartjob();
STATIC struct job *getjob();
STATIC void freejob();
STATIC int procrunning();
STATIC int dowait();
STATIC int waitproc();
#endif
STATIC void restartjob __P((struct job *));
STATIC void freejob __P((struct job *));
STATIC struct job *getjob __P((char *));
STATIC int dowait __P((int, struct job *));
STATIC int onsigchild __P((void));
STATIC int waitproc __P((int, int *));
STATIC void cmdtxt __P((union node *));
STATIC void cmdputs __P((char *));
/*
@ -159,6 +154,7 @@ setjobctl(on)
#ifdef mkinit
INCLUDE <stdlib.h>
SHELLPROC {
backgndpid = -1;
@ -465,6 +461,8 @@ currentjob:
}
}
error("No such job: %s", name);
/*NOTREACHED*/
return NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: jobs.h,v 1.7 1995/03/21 09:09:19 cgd Exp $ */
/* $NetBSD: jobs.h,v 1.8 1995/05/11 21:29:19 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)jobs.h 8.1 (Berkeley) 5/31/93
* @(#)jobs.h 8.2 (Berkeley) 5/4/95
*/
/* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */
@ -79,22 +79,18 @@ struct job {
extern short backgndpid; /* pid of last background process */
extern int job_warning; /* user was warned about stopped jobs */
#ifdef __STDC__
void setjobctl(int);
void showjobs(int);
struct job *makejob(union node *, int);
int forkshell(struct job *, union node *, int);
int waitforjob(struct job *);
char *commandtext(union node *);
#else
void setjobctl();
void showjobs();
struct job *makejob();
int forkshell();
int waitforjob();
char *commandtext();
#endif
void setjobctl __P((int));
int fgcmd __P((int, char **));
int bgcmd __P((int, char **));
int jobscmd __P((int, char **));
void showjobs __P((int));
int waitcmd __P((int, char **));
int jobidcmd __P((int, char **));
struct job *makejob __P((union node *, int));
int forkshell __P((struct job *, union node *, int));
int waitforjob __P((struct job *));
int stoppedjobs __P((void));
char *commandtext __P((union node *));
#if ! JOBS
#define setjobctl(on) /* do nothing */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.h,v 1.7 1995/03/21 09:09:20 cgd Exp $ */
/* $NetBSD: machdep.h,v 1.8 1995/05/11 21:29:21 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)machdep.h 8.1 (Berkeley) 5/31/93
* @(#)machdep.h 8.2 (Berkeley) 5/4/95
*/
/*
@ -49,5 +49,5 @@ union align {
char *cp;
};
#define ALIGN(nbytes) ((nbytes) + sizeof(union align) - 1 &~ (sizeof(union align) - 1))
#define ALIGN(nbytes) (((nbytes) + sizeof(union align) - 1) & ~(sizeof(union align) - 1))
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: mail.c,v 1.8 1995/03/21 09:09:22 cgd Exp $ */
/* $NetBSD: mail.c,v 1.9 1995/05/11 21:29:22 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)mail.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: mail.c,v 1.8 1995/03/21 09:09:22 cgd Exp $";
static char rcsid[] = "$NetBSD: mail.c,v 1.9 1995/05/11 21:29:22 christos Exp $";
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mail.h,v 1.7 1995/03/21 09:09:23 cgd Exp $ */
/* $NetBSD: mail.h,v 1.8 1995/05/11 21:29:23 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,11 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)mail.h 8.1 (Berkeley) 5/31/93
* @(#)mail.h 8.2 (Berkeley) 5/4/95
*/
#ifdef __STDC__
void chkmail(int);
#else
void chkmail();
#endif
void chkmail __P((int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.17 1995/03/21 09:09:26 cgd Exp $ */
/* $NetBSD: main.c,v 1.18 1995/05/11 21:29:25 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -44,9 +44,9 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: main.c,v 1.17 1995/03/21 09:09:26 cgd Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.18 1995/05/11 21:29:25 christos Exp $";
#endif
#endif /* not lint */
@ -55,6 +55,8 @@ static char rcsid[] = "$NetBSD: main.c,v 1.17 1995/03/21 09:09:26 cgd Exp $";
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include "shell.h"
#include "main.h"
#include "mail.h"
@ -67,12 +69,12 @@ static char rcsid[] = "$NetBSD: main.c,v 1.17 1995/03/21 09:09:26 cgd Exp $";
#include "input.h"
#include "trap.h"
#include "var.h"
#include "show.h"
#include "memalloc.h"
#include "error.h"
#include "init.h"
#include "mystring.h"
#include "exec.h"
#include "extern.h"
#define PROFILE 0
@ -86,14 +88,8 @@ short profile_buf[16384];
extern int etext();
#endif
#ifdef __STDC__
STATIC void read_profile(char *);
char *getenv(char *);
#else
STATIC void read_profile();
char *getenv();
#endif
STATIC void read_profile __P((char *));
STATIC char *find_dot_file __P((char *));
/*
* Main routine. We initialize things, parse the arguments, execute
@ -188,6 +184,8 @@ state4: /* XXX ??? - why isn't this before the "if" statement */
monitor(0);
#endif
exitshell(exitstatus);
/*NOTREACHED*/
return 0;
}
@ -290,8 +288,10 @@ readcmdfile(name)
*/
static char *
find_dot_file(basename) char *basename; {
STATIC char *
find_dot_file(basename)
char *basename;
{
static char localname[FILENAME_MAX+1];
char *fullname;
char *path = pathval();
@ -333,10 +333,12 @@ exitcmd(argc, argv)
char **argv;
{
if (stoppedjobs())
return;
return 0;
if (argc > 1)
exitstatus = number(argv[1]);
exitshell(exitstatus);
/*NOTREACHED*/
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.h,v 1.7 1995/03/21 09:09:28 cgd Exp $ */
/* $NetBSD: main.h,v 1.8 1995/05/11 21:29:27 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,16 +35,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)main.h 8.1 (Berkeley) 5/31/93
* @(#)main.h 8.2 (Berkeley) 5/4/95
*/
extern int rootpid; /* pid of main shell */
extern int rootshell; /* true if we aren't a child of the main shell */
#ifdef __STDC__
void readcmdfile(char *);
void cmdloop(int);
#else
void readcmdfile();
void cmdloop();
#endif
void readcmdfile __P((char *));
void cmdloop __P((int));
int dotcmd __P((int, char **));
int exitcmd __P((int, char **));

View File

@ -1,4 +1,4 @@
/* $NetBSD: memalloc.c,v 1.15 1995/03/21 09:09:29 cgd Exp $ */
/* $NetBSD: memalloc.c,v 1.16 1995/05/11 21:29:29 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)memalloc.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: memalloc.c,v 1.15 1995/03/21 09:09:29 cgd Exp $";
static char rcsid[] = "$NetBSD: memalloc.c,v 1.16 1995/05/11 21:29:29 christos Exp $";
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: memalloc.h,v 1.9 1995/03/21 09:09:31 cgd Exp $ */
/* $NetBSD: memalloc.h,v 1.10 1995/05/11 21:29:31 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)memalloc.h 8.1 (Berkeley) 5/31/93
* @(#)memalloc.h 8.2 (Berkeley) 5/4/95
*/
struct stackmark {
@ -50,35 +50,18 @@ extern int stacknleft;
extern int sstrnleft;
extern int herefd;
#ifdef __STDC__
pointer ckmalloc(int);
pointer ckrealloc(pointer, int);
void free(pointer); /* defined in C library */
char *savestr(char *);
pointer stalloc(int);
void stunalloc(pointer);
void setstackmark(struct stackmark *);
void popstackmark(struct stackmark *);
void growstackblock(void);
void grabstackblock(int);
char *growstackstr(void);
char *makestrspace(void);
void ungrabstackstr(char *, char *);
#else
pointer ckmalloc();
pointer ckrealloc();
void free(); /* defined in C library */
char *savestr();
pointer stalloc();
void stunalloc();
void setstackmark();
void popstackmark();
void growstackblock();
void grabstackblock();
char *growstackstr();
char *makestrspace();
void ungrabstackstr();
#endif
pointer ckmalloc __P((int));
pointer ckrealloc __P((pointer, int));
char *savestr __P((char *));
pointer stalloc __P((int));
void stunalloc __P((pointer));
void setstackmark __P((struct stackmark *));
void popstackmark __P((struct stackmark *));
void growstackblock __P((void));
void grabstackblock __P((int));
char *growstackstr __P((void));
char *makestrspace __P((void));
void ungrabstackstr __P((char *, char *));
@ -86,7 +69,7 @@ void ungrabstackstr();
#define stackblocksize() stacknleft
#define STARTSTACKSTR(p) p = stackblock(), sstrnleft = stackblocksize()
#define STPUTC(c, p) (--sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(), *p++ = (c)))
#define CHECKSTRSPACE(n, p) if (sstrnleft < n) p = makestrspace(); else
#define CHECKSTRSPACE(n, p) { if (sstrnleft < n) p = makestrspace(); }
#define USTPUTC(c, p) (--sstrnleft, *p++ = (c))
#define STACKSTRNUL(p) (sstrnleft == 0? (p = growstackstr(), *p = '\0') : (*p = '\0'))
#define STUNPUTC(p) (++sstrnleft, --p)

View File

@ -1,4 +1,4 @@
/* $NetBSD: miscbltin.c,v 1.13 1995/03/21 09:09:33 cgd Exp $ */
/* $NetBSD: miscbltin.c,v 1.14 1995/05/11 21:29:32 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)miscbltin.c 8.2 (Berkeley) 4/16/94";
static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: miscbltin.c,v 1.13 1995/03/21 09:09:33 cgd Exp $";
static char rcsid[] = "$NetBSD: miscbltin.c,v 1.14 1995/05/11 21:29:32 christos Exp $";
#endif
#endif /* not lint */
@ -50,8 +50,11 @@ static char rcsid[] = "$NetBSD: miscbltin.c,v 1.13 1995/03/21 09:09:33 cgd Exp $
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <ctype.h>
#include "shell.h"
#include "options.h"
#include "var.h"
@ -230,3 +233,161 @@ umaskcmd(argc, argv)
}
return 0;
}
/*
* ulimit builtin
*
* This code, originally by Doug Gwyn, Doug Kingston, Eric Gisin, and
* Michael Rendell was ripped from pdksh 5.0.8 and hacked for use with
* ash by J.T. Conklin.
*
* Public domain.
*/
struct limits {
const char *name;
int cmd;
int factor; /* multiply by to get rlim_{cur,max} values */
char option;
};
static const struct limits limits[] = {
#ifdef RLIMIT_CPU
{ "time(seconds)", RLIMIT_CPU, 1, 't' },
#endif
#ifdef RLIMIT_FSIZE
{ "file(blocks)", RLIMIT_FSIZE, 512, 'f' },
#endif
#ifdef RLIMIT_DATA
{ "data(kbytes)", RLIMIT_DATA, 1024, 'd' },
#endif
#ifdef RLIMIT_STACK
{ "stack(kbytes)", RLIMIT_STACK, 1024, 's' },
#endif
#ifdef RLIMIT_CORE
{ "coredump(blocks)", RLIMIT_CORE, 512, 'c' },
#endif
#ifdef RLIMIT_RSS
{ "memory(kbytes)", RLIMIT_RSS, 1024, 'm' },
#endif
#ifdef RLIMIT_MEMLOCK
{ "locked memory(kbytes)", RLIMIT_MEMLOCK, 1024, 'l' },
#endif
#ifdef RLIMIT_NPROC
{ "process(processes)", RLIMIT_NPROC, 1, 'p' },
#endif
#ifdef RLIMIT_NOFILE
{ "nofiles(descriptors)", RLIMIT_NOFILE, 1, 'n' },
#endif
#ifdef RLIMIT_VMEM
{ "vmemory(kbytes)", RLIMIT_VMEM, 1024, 'v' },
#endif
#ifdef RLIMIT_SWAP
{ "swap(kbytes)", RLIMIT_SWAP, 1024, 'w' },
#endif
{ (char *) 0, 0, 0, '\0' }
};
int
ulimitcmd(argc, argv)
int argc;
char **argv;
{
register int c;
quad_t val;
enum { SOFT = 0x1, HARD = 0x2 }
how = SOFT | HARD;
const struct limits *l;
int set, all = 0;
int optc, what;
struct rlimit limit;
what = 'f';
while ((optc = nextopt("HSatfdsmcnpl")) != '\0')
switch (optc) {
case 'H':
how = HARD;
break;
case 'S':
how = SOFT;
break;
case 'a':
all = 1;
break;
default:
what = optc;
}
for (l = limits; l->name && l->option != what; l++)
;
if (!l->name)
error("ulimit: internal error (%c)\n", what);
set = *argptr ? 1 : 0;
if (set) {
char *p = *argptr;
if (all || argptr[1])
error("ulimit: too many arguments\n");
if (strcmp(p, "unlimited") == 0)
val = RLIM_INFINITY;
else {
val = (quad_t) 0;
while ((c = *p++) >= '0' && c <= '9')
{
val = (val * 10) + (long)(c - '0');
if (val < (quad_t) 0)
break;
}
if (c)
error("ulimit: bad number\n");
val *= l->factor;
}
}
if (all) {
for (l = limits; l->name; l++) {
getrlimit(l->cmd, &limit);
if (how & SOFT)
val = limit.rlim_cur;
else if (how & HARD)
val = limit.rlim_max;
out1fmt("%-20s ", l->name);
if (val == RLIM_INFINITY)
out1fmt("unlimited\n");
else
{
val /= l->factor;
out1fmt("%ld\n", (long) val);
}
}
return 0;
}
getrlimit(l->cmd, &limit);
if (set) {
if (how & SOFT)
limit.rlim_cur = val;
if (how & HARD)
limit.rlim_max = val;
if (setrlimit(l->cmd, &limit) < 0)
error("ulimit: bad limit\n");
} else {
if (how & SOFT)
val = limit.rlim_cur;
else if (how & HARD)
val = limit.rlim_max;
}
if (!set) {
if (val == RLIM_INFINITY)
out1fmt("unlimited\n");
else
{
val /= l->factor;
out1fmt("%ld\n", (long) val);
}
}
return 0;
}

View File

@ -1,5 +1,5 @@
#!/bin/sh -
# $NetBSD: mkbuiltins,v 1.11 1995/03/21 09:09:34 cgd Exp $
# $NetBSD: mkbuiltins,v 1.12 1995/05/11 21:29:33 christos Exp $
#
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
@ -35,7 +35,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)mkbuiltins 8.1 (Berkeley) 5/31/93
# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95
temp=/tmp/ka$$
havejobs=0
@ -68,9 +68,9 @@ 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 > ${objdir}/builtins.h

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkinit.c,v 1.12 1995/03/21 09:09:36 cgd Exp $ */
/* $NetBSD: mkinit.c,v 1.13 1995/05/11 21:29:34 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -44,9 +44,9 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)mkinit.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: mkinit.c,v 1.12 1995/03/21 09:09:36 cgd Exp $";
static char rcsid[] = "$NetBSD: mkinit.c,v 1.13 1995/05/11 21:29:34 christos Exp $";
#endif
#endif /* not lint */
@ -156,16 +156,22 @@ struct text decls; /* declarations */
int amiddecls; /* for formatting */
void readfile(), doevent(), doinclude(), dodecl(), output();
void addstr(), addchar(), writetext();
FILE *ckfopen();
void *ckmalloc __P((int));
void error();
int file_changed();
void readfile __P((char *));
int match __P((char *, char *));
int gooddefine __P((char *));
char *savestr();
void doevent __P((struct event *, FILE *, char *));
void doinclude __P((char *));
void dodecl __P((char *, FILE *));
void output __P((void));
int file_changed __P((void));
int touch __P((char *));
void addstr __P((char *, struct text *));
void addchar __P((int, struct text *));
void writetext __P((struct text *, FILE *));
FILE *ckfopen __P((char *, char *));
void *ckmalloc __P((int));
char *savestr __P((char *));
void error __P((char *));
#define equal(s1, s2) (strcmp(s1, s2) == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mknodes.c,v 1.10 1995/03/21 09:09:38 cgd Exp $ */
/* $NetBSD: mknodes.c,v 1.11 1995/05/11 21:29:36 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -44,9 +44,9 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)mknodes.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: mknodes.c,v 1.10 1995/03/21 09:09:38 cgd Exp $";
static char rcsid[] = "$NetBSD: mknodes.c,v 1.11 1995/05/11 21:29:36 christos Exp $";
#endif
#endif /* not lint */
@ -58,6 +58,11 @@ static char rcsid[] = "$NetBSD: mknodes.c,v 1.10 1995/03/21 09:09:38 cgd Exp $";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#define MAXTYPES 50 /* max number of node types */
@ -88,28 +93,28 @@ struct str { /* struct representing a node structure */
};
int ntypes; /* number of node types */
char *nodename[MAXTYPES]; /* names of the nodes */
struct str *nodestr[MAXTYPES]; /* type of structure used by the node */
int nstr; /* number of structures */
struct str str[MAXTYPES]; /* the structures */
struct str *curstr; /* current structure */
FILE *infp = stdin;
char line[1024];
int linno;
char *linep;
static int ntypes; /* number of node types */
static char *nodename[MAXTYPES]; /* names of the nodes */
static struct str *nodestr[MAXTYPES]; /* type of structure used by the node */
static int nstr; /* number of structures */
static struct str str[MAXTYPES]; /* the structures */
static struct str *curstr; /* current structure */
static FILE *infp = stdin;
static char line[1024];
static int linno;
static char *linep;
void indent __P((int, FILE *));
int nextfield __P((char *));
void outfunc __P((FILE *, int));
void output __P((char *));
void outsizes __P((FILE *));
void parsefield();
void parsenode();
int readline();
char *savestr();
void skipbl();
#define equal(s1, s2) (strcmp(s1, s2) == 0)
static void parsenode __P((void));
static void parsefield __P((void));
static void output __P((char *));
static void outsizes __P((FILE *));
static void outfunc __P((FILE *, int));
static void indent __P((int, FILE *));
static int nextfield __P((char *));
static void skipbl __P((void));
static int readline __P((void));
static void error __P((const char *, ...));
static char *savestr __P((const char *));
int
@ -133,8 +138,9 @@ main(argc, argv)
void
parsenode() {
static void
parsenode()
{
char name[BUFLEN];
char tag[BUFLEN];
struct str *sp;
@ -148,7 +154,7 @@ parsenode() {
error("Garbage at end of line");
nodename[ntypes] = savestr(name);
for (sp = str ; sp < str + nstr ; sp++) {
if (equal(sp->tag, tag))
if (strcmp(sp->tag, tag) == 0)
break;
}
if (sp >= str + nstr) {
@ -162,8 +168,9 @@ parsenode() {
}
void
parsefield() {
static void
parsefield()
{
char name[BUFLEN];
char type[BUFLEN];
char decl[2 * BUFLEN];
@ -177,21 +184,21 @@ parsefield() {
error("No field type");
fp = &curstr->field[curstr->nfields];
fp->name = savestr(name);
if (equal(type, "nodeptr")) {
if (strcmp(type, "nodeptr") == 0) {
fp->type = T_NODE;
sprintf(decl, "union node *%s", name);
} else if (equal(type, "nodelist")) {
} else if (strcmp(type, "nodelist") == 0) {
fp->type = T_NODELIST;
sprintf(decl, "struct nodelist *%s", name);
} else if (equal(type, "string")) {
} else if (strcmp(type, "string") == 0) {
fp->type = T_STRING;
sprintf(decl, "char *%s", name);
} else if (equal(type, "int")) {
} else if (strcmp(type, "int") == 0) {
fp->type = T_INT;
sprintf(decl, "int %s", name);
} else if (equal(type, "other")) {
} else if (strcmp(type, "other") == 0) {
fp->type = T_OTHER;
} else if (equal(type, "temp")) {
} else if (strcmp(type, "temp") == 0) {
fp->type = T_TEMP;
} else {
error("Unknown type %s", type);
@ -214,7 +221,7 @@ char writer[] = "\
*/\n\
\n";
void
static void
output(file)
char *file;
{
@ -264,11 +271,11 @@ output(file)
fputs(writer, cfile);
while (fgets(line, sizeof line, patfile) != NULL) {
for (p = line ; *p == ' ' || *p == '\t' ; p++);
if (equal(p, "%SIZES\n"))
if (strcmp(p, "%SIZES\n") == 0)
outsizes(cfile);
else if (equal(p, "%CALCSIZE\n"))
else if (strcmp(p, "%CALCSIZE\n") == 0)
outfunc(cfile, 1);
else if (equal(p, "%COPY\n"))
else if (strcmp(p, "%COPY\n") == 0)
outfunc(cfile, 0);
else
fputs(line, cfile);
@ -277,7 +284,7 @@ output(file)
void
static void
outsizes(cfile)
FILE *cfile;
{
@ -291,7 +298,7 @@ outsizes(cfile)
}
void
static void
outfunc(cfile, calcsize)
FILE *cfile;
int calcsize;
@ -372,7 +379,7 @@ outfunc(cfile, calcsize)
}
void
static void
indent(amount, fp)
int amount;
FILE *fp;
@ -387,7 +394,7 @@ indent(amount, fp)
}
int
static int
nextfield(buf)
char *buf;
{
@ -405,15 +412,17 @@ nextfield(buf)
}
void
skipbl() {
static void
skipbl()
{
while (*linep == ' ' || *linep == '\t')
linep++;
}
int
readline() {
static int
readline()
{
register char *p;
if (fgets(line, 1024, infp) == NULL)
@ -431,25 +440,42 @@ readline() {
error(msg, a1, a2, a3, a4, a5, a6)
char *msg;
static void
#if __STDC__
error(const char *msg, ...)
#else
error(va_alist)
va_dcl
#endif
{
fprintf(stderr, "line %d: ", linno);
fprintf(stderr, msg, a1, a2, a3, a4, a5, a6);
putc('\n', stderr);
va_list va;
#if __STDC__
va_start(va, msg);
#else
char *msg;
va_start(va);
msg = va_arg(va, char *);
#endif
(void) fprintf(stderr, "line %d: ", linno);
(void) vfprintf(stderr, msg, va);
(void) fputc('\n', stderr);
va_end(va);
exit(2);
}
char *
static char *
savestr(s)
char *s;
{
const char *s;
{
register char *p;
if ((p = malloc(strlen(s) + 1)) == NULL)
error("Out of space");
strcpy(p, s);
(void) strcpy(p, s);
return p;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mksyntax.c,v 1.10 1995/03/21 09:09:40 cgd Exp $ */
/* $NetBSD: mksyntax.c,v 1.11 1995/05/11 21:29:37 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -44,9 +44,9 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)mksyntax.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)mksyntax.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: mksyntax.c,v 1.10 1995/03/21 09:09:40 cgd Exp $";
static char rcsid[] = "$NetBSD: mksyntax.c,v 1.11 1995/05/11 21:29:37 christos Exp $";
#endif
#endif /* not lint */
@ -66,21 +66,21 @@ struct synclass {
/* Syntax classes */
struct synclass synclass[] = {
"CWORD", "character is nothing special",
"CNL", "newline character",
"CBACK", "a backslash character",
"CSQUOTE", "single quote",
"CDQUOTE", "double quote",
"CENDQUOTE", "a terminating quote",
"CBQUOTE", "backwards single quote",
"CVAR", "a dollar sign",
"CENDVAR", "a '}' character",
"CLP", "a left paren in arithmetic",
"CRP", "a right paren in arithmetic",
"CEOF", "end of file",
"CCTL", "like CWORD, except it must be escaped",
"CSPCL", "these terminate a word",
NULL, NULL
{ "CWORD", "character is nothing special" },
{ "CNL", "newline character" },
{ "CBACK", "a backslash character" },
{ "CSQUOTE", "single quote" },
{ "CDQUOTE", "double quote" },
{ "CENDQUOTE", "a terminating quote" },
{ "CBQUOTE", "backwards single quote" },
{ "CVAR", "a dollar sign" },
{ "CENDVAR", "a '}' character" },
{ "CLP", "a left paren in arithmetic" },
{ "CRP", "a right paren in arithmetic" },
{ "CEOF", "end of file" },
{ "CCTL", "like CWORD, except it must be escaped" },
{ "CSPCL", "these terminate a word" },
{ NULL, NULL }
};
@ -89,40 +89,40 @@ struct synclass synclass[] = {
* you may have to change the definition of the is_in_name macro.
*/
struct synclass is_entry[] = {
"ISDIGIT", "a digit",
"ISUPPER", "an upper case letter",
"ISLOWER", "a lower case letter",
"ISUNDER", "an underscore",
"ISSPECL", "the name of a special parameter",
NULL, NULL,
{ "ISDIGIT", "a digit" },
{ "ISUPPER", "an upper case letter" },
{ "ISLOWER", "a lower case letter" },
{ "ISUNDER", "an underscore" },
{ "ISSPECL", "the name of a special parameter" },
{ NULL, NULL }
};
char writer[] = "\
static char writer[] = "\
/*\n\
* This file was generated by the mksyntax program.\n\
*/\n\
\n";
FILE *cfile;
FILE *hfile;
char *syntax[513];
int base;
int size; /* number of values which a char variable can have */
int nbits; /* number of bits in a character */
int digit_contig; /* true if digits are contiguous */
static FILE *cfile;
static FILE *hfile;
static char *syntax[513];
static int base;
static int size; /* number of values which a char variable can have */
static int nbits; /* number of bits in a character */
static int digit_contig;/* true if digits are contiguous */
void add __P((char *, char *));
void digit_convert();
void filltable __P((char *));
void init();
void output_type_macros();
void print __P((char *));
static void filltable __P((char *));
static void init __P((void));
static void add __P((char *, char *));
static void print __P((char *));
static void output_type_macros __P((void));
static void digit_convert __P((void));
int
main(argc, argv)
int argc;
char *argv[];
char **argv;
{
char c;
char d;
@ -177,7 +177,7 @@ main(argc, argv)
for (i = 0 ; synclass[i].name ; i++) {
sprintf(buf, "#define %s %d", synclass[i].name, i);
fputs(buf, hfile);
for (pos = strlen(buf) ; pos < 32 ; pos = pos + 8 &~ 07)
for (pos = strlen(buf) ; pos < 32 ; pos = (pos + 8) & ~07)
putc('\t', hfile);
fprintf(hfile, "/* %s */\n", synclass[i].comment);
}
@ -186,7 +186,7 @@ main(argc, argv)
for (i = 0 ; is_entry[i].name ; i++) {
sprintf(buf, "#define %s %#o", is_entry[i].name, 1 << i);
fputs(buf, hfile);
for (pos = strlen(buf) ; pos < 32 ; pos = pos + 8 &~ 07)
for (pos = strlen(buf) ; pos < 32 ; pos = (pos + 8) & ~07)
putc('\t', hfile);
fprintf(hfile, "/* %s */\n", is_entry[i].comment);
}
@ -265,7 +265,7 @@ main(argc, argv)
* Clear the syntax table.
*/
void
static void
filltable(dftval)
char *dftval;
{
@ -280,8 +280,9 @@ filltable(dftval)
* Initialize the syntax table with default values.
*/
void
init() {
static void
init()
{
filltable("CWORD");
syntax[0] = "CEOF";
syntax[base + CTLESC] = "CCTL";
@ -298,7 +299,7 @@ init() {
* Add entries to the syntax table.
*/
void
static void
add(p, type)
char *p, *type;
{
@ -312,7 +313,7 @@ add(p, type)
* Output the syntax table.
*/
void
static void
print(name)
char *name;
{
@ -346,7 +347,7 @@ print(name)
* contiguous, we can test for them quickly.
*/
char *macro[] = {
static char *macro[] = {
"#define is_digit(c)\t((is_type+SYNBASE)[c] & ISDIGIT)",
"#define is_alpha(c)\t((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER))",
"#define is_name(c)\t((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER|ISUNDER))",
@ -355,7 +356,7 @@ char *macro[] = {
NULL
};
void
static void
output_type_macros()
{
char **pp;
@ -376,7 +377,7 @@ output_type_macros()
* Output digit conversion table (if digits are not contiguous).
*/
void
static void
digit_convert()
{
int maxdigit;

View File

@ -1,5 +1,5 @@
#!/bin/sh -
# $NetBSD: mktokens,v 1.6 1995/03/21 09:09:42 cgd Exp $
# $NetBSD: mktokens,v 1.7 1995/05/11 21:29:38 christos Exp $
#
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.

View File

@ -1,4 +1,4 @@
/* $NetBSD: myhistedit.h,v 1.3 1995/03/21 09:09:43 cgd Exp $ */
/* $NetBSD: myhistedit.h,v 1.4 1995/05/11 21:29:40 christos Exp $ */
/*-
* Copyright (c) 1993
@ -32,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)myhistedit.h 8.1 (Berkeley) 5/31/93
* @(#)myhistedit.h 8.2 (Berkeley) 5/4/95
*/
#include <histedit.h>
@ -40,3 +40,10 @@
extern History *hist;
extern EditLine *el;
extern int displayhist;
void histedit __P((void));
void sethistsize __P((void));
int histcmd __P((int, char **));
int not_fcnumber __P((char *));
int str_to_event __P((char *, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: mystring.c,v 1.9 1995/03/21 09:09:45 cgd Exp $ */
/* $NetBSD: mystring.c,v 1.10 1995/05/11 21:29:41 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)mystring.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: mystring.c,v 1.9 1995/03/21 09:09:45 cgd Exp $";
static char rcsid[] = "$NetBSD: mystring.c,v 1.10 1995/05/11 21:29:41 christos Exp $";
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mystring.h,v 1.8 1995/03/21 09:09:46 cgd Exp $ */
/* $NetBSD: mystring.h,v 1.9 1995/05/11 21:29:42 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,22 +35,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)mystring.h 8.1 (Berkeley) 5/31/93
* @(#)mystring.h 8.2 (Berkeley) 5/4/95
*/
#include <string.h>
#ifdef __STDC__
void scopyn(const char *, char *, int);
int prefix(const char *, const char *);
int number(const char *);
int is_number(const char *);
#else
void scopyn();
int prefix();
int number();
int is_number();
#endif
void scopyn __P((const char *, char *, int));
int prefix __P((const char *, const char *));
int number __P((const char *));
int is_number __P((const char *));
#define equal(s1, s2) (strcmp(s1, s2) == 0)
#define scopy(s1, s2) ((void)strcpy(s2, s1))

View File

@ -1,4 +1,4 @@
/* $NetBSD: nodes.c.pat,v 1.6 1995/03/21 09:09:47 cgd Exp $ */
/* $NetBSD: nodes.c.pat,v 1.7 1995/05/11 21:29:43 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,9 +35,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)nodes.c.pat 8.1 (Berkeley) 5/31/93
* @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
*/
#include <stdlib.h>
/*
* Routine for dealing with parsed shell commands.
*/
@ -49,31 +50,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 *));
@ -83,85 +72,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;
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;
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;
char *s;
{
register char *p = s;
register char *q = funcstring;
char *rtn = funcstring;
while (*q++ = *p++);
funcstring = q;
return rtn;
while ((*q++ = *p++) != '\0')
continue;
funcstring = q;
return rtn;
}
@ -172,8 +162,8 @@ nodesavestr(s)
void
freefunc(n)
union node *n;
{
if (n)
ckfree(n);
union node *n;
{
if (n)
ckfree(n);
}

View File

@ -1,5 +1,4 @@
# $NetBSD: nodetypes,v 1.7 1995/03/21 09:09:49 cgd Exp $
#
# $NetBSD: nodetypes,v 1.8 1995/05/11 21:29:44 christos Exp $
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
#
@ -34,7 +33,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)nodetypes 8.1 (Berkeley) 5/31/93
# @(#)nodetypes 8.2 (Berkeley) 5/4/95
# This file describes the nodes used in parse trees. Unindented lines
# contain a node type followed by a structure tag. Subsequent indented
@ -133,6 +132,7 @@ NFROMFD ndup # fd>&dupfd
dupfd int # file descriptor to duplicate
vname nodeptr # file name if fd>&$var
NHERE nhere # fd<<\!
NXHERE nhere # fd<<!
type int

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.13 1995/03/26 17:25:10 christos Exp $ */
/* $NetBSD: options.c,v 1.14 1995/05/11 21:29:46 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,12 +38,16 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)options.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: options.c,v 1.13 1995/03/26 17:25:10 christos Exp $";
static char rcsid[] = "$NetBSD: options.c,v 1.14 1995/05/11 21:29:46 christos Exp $";
#endif
#endif /* not lint */
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include "shell.h"
#define DEFINE_OPTIONS
#include "options.h"
@ -58,8 +62,9 @@ static char rcsid[] = "$NetBSD: options.c,v 1.13 1995/03/26 17:25:10 christos Ex
#include "memalloc.h"
#include "error.h"
#include "mystring.h"
#include "extern.h"
#include <unistd.h>
#ifndef NO_HISTORY
#include "myhistedit.h"
#endif
char *arg0; /* value of $0 */
struct shparam shellparam; /* current positional parameters */
@ -70,16 +75,9 @@ char *optptr; /* used by nextopt */
char *minusc; /* argument to -c option */
#ifdef __STDC__
STATIC void options(int);
STATIC void setoption(int, int);
STATIC void minus_o(char *, int);
#else
STATIC void options();
STATIC void setoption();
STATIC void minus_o();
#endif
STATIC void options __P((int));
STATIC void minus_o __P((char *, int));
STATIC void setoption __P((int, int));
/*
@ -152,7 +150,7 @@ options(cmdline)
argptr++;
if ((c = *p++) == '-') {
val = 1;
if (p[0] == '\0' || p[0] == '-' && p[1] == '\0') {
if (p[0] == '\0' || (p[0] == '-' && p[1] == '\0')) {
if (!cmdline) {
/* "-" means turn off -x and -v */
if (p[0] == '\0')
@ -242,7 +240,6 @@ setoption(flag, val)
#ifdef mkinit
INCLUDE "options.h"
INCLUDE "extern.h"
SHELLPROC {
int i;

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.h,v 1.7 1995/03/21 09:09:53 cgd Exp $ */
/* $NetBSD: options.h,v 1.8 1995/05/11 21:29:48 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)options.h 8.1 (Berkeley) 5/31/93
* @(#)options.h 8.2 (Berkeley) 5/4/95
*/
struct shparam {
@ -74,21 +74,21 @@ struct optent {
#ifdef DEFINE_OPTIONS
struct optent optlist[NOPTS] = {
"errexit", 'e', 0,
"noglob", 'f', 0,
"ignoreeof", 'I', 0,
"interactive", 'i', 0,
"monitor", 'm', 0,
"noexec", 'n', 0,
"stdin", 's', 0,
"xtrace", 'x', 0,
"verbose", 'v', 0,
"vi", 'V', 0,
"emacs", 'E', 0,
"noclobber", 'C', 0,
"allexport", 'a', 0,
"notify", 'b', 0,
"nounset", 'u', 0,
{ "errexit", 'e', 0 },
{ "noglob", 'f', 0 },
{ "ignoreeof", 'I', 0 },
{ "interactive",'i', 0 },
{ "monitor", 'm', 0 },
{ "noexec", 'n', 0 },
{ "stdin", 's', 0 },
{ "xtrace", 'x', 0 },
{ "verbose", 'v', 0 },
{ "vi", 'V', 0 },
{ "emacs", 'E', 0 },
{ "noclobber", 'C', 0 },
{ "allexport", 'a', 0 },
{ "notify", 'b', 0 },
{ "nounset", 'u', 0 },
};
#else
extern struct optent optlist[NOPTS];
@ -102,15 +102,11 @@ extern char **argptr; /* argument list for builtin commands */
extern char *optarg; /* set by nextopt */
extern char *optptr; /* used by nextopt */
#ifdef __STDC__
void procargs(int, char **);
void setparam(char **);
void freeparam(struct shparam *);
int nextopt(char *);
#else
void procargs();
void setparam();
void freeparam();
int nextopt();
#endif
void procargs __P((int, char **));
void optschanged __P((void));
void setparam __P((char **));
void freeparam __P((struct shparam *));
int shiftcmd __P((int, char **));
int setcmd __P((int, char **));
int getoptscmd __P((int, char **));
int nextopt __P((char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: output.c,v 1.13 1995/03/21 09:09:55 cgd Exp $ */
/* $NetBSD: output.c,v 1.14 1995/05/11 21:29:50 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,9 +38,9 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)output.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: output.c,v 1.13 1995/03/21 09:09:55 cgd Exp $";
static char rcsid[] = "$NetBSD: output.c,v 1.14 1995/05/11 21:29:50 christos Exp $";
#endif
#endif /* not lint */
@ -59,18 +59,20 @@ static char rcsid[] = "$NetBSD: output.c,v 1.13 1995/03/21 09:09:55 cgd Exp $";
#include <stdio.h> /* defines BUFSIZ */
#include <string.h>
#include "shell.h"
#include "syntax.h"
#include "output.h"
#include "memalloc.h"
#include "error.h"
#ifdef __STDC__
#include "stdarg.h"
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "shell.h"
#include "syntax.h"
#include "output.h"
#include "memalloc.h"
#include "error.h"
#define OUTBUFSIZ BUFSIZ

View File

@ -1,4 +1,4 @@
/* $NetBSD: output.h,v 1.10 1995/03/21 09:09:57 cgd Exp $ */
/* $NetBSD: output.h,v 1.11 1995/05/11 21:29:53 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,11 +35,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)output.h 8.1 (Berkeley) 5/31/93
* @(#)output.h 8.2 (Berkeley) 5/4/95
*/
#ifndef OUTPUT_INCL
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
struct output {
char *nextc;
int nleft;
@ -55,38 +61,21 @@ extern struct output memout;
extern struct output *out1;
extern struct output *out2;
#ifdef __STDC__
void outstr(const char *, struct output *);
void out1str(const char *);
void out2str(const char *);
void outfmt(struct output *, char *, ...);
void out1fmt(char *, ...);
void fmtstr(char *, int, char *, ...);
/* void doformat(struct output *, char *, va_list); */
void doformat();
void emptyoutbuf(struct output *);
void flushall(void);
void flushout(struct output *);
void freestdout(void);
int xwrite(int, char *, int);
int xioctl(int, unsigned long, char *);
#else
void outstr();
void out1str();
void out2str();
void outfmt();
void out1fmt();
void fmtstr();
/* void doformat(); */
void doformat();
void emptyoutbuf();
void flushall();
void flushout();
void freestdout();
int xwrite();
int xioctl();
#endif
void open_mem __P((char *, int, struct output *));
void out1str __P((const char *));
void out2str __P((const char *));
void outstr __P((const char *, struct output *));
void emptyoutbuf __P((struct output *));
void flushall __P((void));
void flushout __P((struct output *));
void freestdout __P((void));
void outfmt __P((struct output *, char *, ...));
void out1fmt __P((char *, ...));
void dprintf __P((char *, ...));
void fmtstr __P((char *, int, char *, ...));
void doformat __P((struct output *, char *, va_list));
int xwrite __P((int, char *, int));
int xioctl __P((int, unsigned long, char *));
#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
#define out1c(c) outc(c, out1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: parser.c,v 1.24 1995/03/21 09:09:59 cgd Exp $ */
/* $NetBSD: parser.c,v 1.25 1995/05/11 21:29:55 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,12 +38,14 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)parser.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)parser.c 8.6 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: parser.c,v 1.24 1995/03/21 09:09:59 cgd Exp $";
static char rcsid[] = "$NetBSD: parser.c,v 1.25 1995/05/11 21:29:55 christos Exp $";
#endif
#endif /* not lint */
#include <stdlib.h>
#include "shell.h"
#include "parser.h"
#include "nodes.h"
@ -58,6 +60,7 @@ static char rcsid[] = "$NetBSD: parser.c,v 1.24 1995/03/21 09:09:59 cgd Exp $";
#include "memalloc.h"
#include "mystring.h"
#include "alias.h"
#include "show.h"
#ifndef NO_HISTORY
#include "myhistedit.h"
#endif
@ -112,14 +115,14 @@ STATIC union node *simplecmd __P((union node **, union node *));
STATIC union node *makename __P((void));
STATIC void parsefname __P((void));
STATIC void parseheredoc __P((void));
STATIC int readtoken __P((void));
STATIC int readtoken1 __P((int, char const *, char *, int));
STATIC void attyline __P((void));
STATIC int noexpand __P((char *));
STATIC int peektoken __P((void));
STATIC int readtoken __P((void));
STATIC int xxreadtoken __P((void));
STATIC int readtoken1 __P((int, char const *, char *, int));
STATIC int noexpand __P((char *));
STATIC void synexpect __P((int));
STATIC void synerror __P((char *));
STATIC void setprompt __P((int));
STATIC void setprompt __P((int));
/*
@ -296,7 +299,8 @@ command() {
int t;
checkkwd = 2;
redir = 0;
redir = NULL;
n1 = NULL;
rpp = &redir;
/* Check for redirection which may precede command */
while (readtoken() == TREDIR) {
@ -710,7 +714,7 @@ readtoken() {
goto out;
}
}
if (ap = lookupalias(wordtext, 1)) {
if ((ap = lookupalias(wordtext, 1)) != NULL) {
pushstring(ap->val, strlen(ap->val), ap);
checkkwd = savecheckkwd;
goto top;
@ -846,8 +850,8 @@ readtoken1(firstc, syntax, eofmark, striptabs)
char *eofmark;
int striptabs;
{
register c = firstc;
register char *out;
int c = firstc;
char *out;
int len;
char line[EOFMARKLEN + 1];
struct nodelist *bqlist;
@ -858,6 +862,18 @@ readtoken1(firstc, syntax, eofmark, striptabs)
int parenlevel; /* levels of parens in arithmetic */
int oldstyle;
char const *prevsyntax; /* syntax before arithmetic */
#if __GNUC__
/* Avoid longjmp clobbering */
(void) &out;
(void) &quotef;
(void) &dblquote;
(void) &varnest;
(void) &arinest;
(void) &parenlevel;
(void) &oldstyle;
(void) &prevsyntax;
(void) &syntax;
#endif
startlinno = plinno;
dblquote = 0;
@ -1258,8 +1274,8 @@ parsebackq: {
if (savelen > 0) {
str = ckmalloc(savelen);
memcpy(str, stackblock(), savelen);
setinputstring(str, 1);
}
setinputstring(str, 1);
}
nlpp = &bqlist;
while (*nlpp)

View File

@ -1,4 +1,4 @@
/* $NetBSD: parser.h,v 1.9 1995/03/21 09:10:01 cgd Exp $ */
/* $NetBSD: parser.h,v 1.10 1995/05/11 21:30:02 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)parser.h 8.1 (Berkeley) 5/31/93
* @(#)parser.h 8.3 (Berkeley) 5/4/95
*/
/* control characters in argument strings */
@ -76,14 +76,7 @@ extern int tokpushback;
extern int whichprompt; /* 1 == PS1, 2 == PS2 */
#ifdef __STDC__
union node *parsecmd(int);
int goodname(char *);
char *getprompt(void *);
void fixredir(union node *, const char *, int);
#else
union node *parsecmd();
int goodname();
char *getprompt();
void fixredir();
#endif
union node *parsecmd __P((int));
void fixredir __P((union node *, const char *, int));
int goodname __P((char *));
char *getprompt __P((void *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: redir.c,v 1.11 1995/03/21 09:10:04 cgd Exp $ */
/* $NetBSD: redir.c,v 1.12 1995/05/11 21:30:10 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,12 +38,20 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)redir.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: redir.c,v 1.11 1995/03/21 09:10:04 cgd Exp $";
static char rcsid[] = "$NetBSD: redir.c,v 1.12 1995/05/11 21:30:10 christos Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
/*
* Code for dealing with input/output redirection.
*/
@ -56,12 +64,6 @@ static char rcsid[] = "$NetBSD: redir.c,v 1.11 1995/03/21 09:10:04 cgd Exp $";
#include "output.h"
#include "memalloc.h"
#include "error.h"
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#define EMPTY -2 /* marks an unused slot in redirtab */
@ -84,14 +86,8 @@ MKINIT struct redirtab *redirlist;
*/
int fd0_redirected = 0;
#ifdef __STDC__
STATIC void openredirect(union node *, char *);
STATIC int openhere(union node *);
#else
STATIC void openredirect();
STATIC int openhere();
#endif
STATIC void openredirect __P((union node *, char[10 ]));
STATIC int openhere __P((union node *));
/*
@ -228,7 +224,7 @@ openhere(redir)
union node *redir;
{
int pip[2];
int len;
int len = 0;
if (pipe(pip) < 0)
error("Pipe call failed");

View File

@ -1,4 +1,4 @@
/* $NetBSD: redir.h,v 1.8 1995/03/21 09:10:07 cgd Exp $ */
/* $NetBSD: redir.h,v 1.9 1995/05/11 21:30:13 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,24 +35,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)redir.h 8.1 (Berkeley) 5/31/93
* @(#)redir.h 8.2 (Berkeley) 5/4/95
*/
/* flags passed to redirect */
#define REDIR_PUSH 01 /* save previous values of file descriptors */
#define REDIR_BACKQ 02 /* save the command output in memory */
#ifdef __STDC__
union node;
void redirect(union node *, int);
void popredir(void);
void clearredir(void);
int copyfd(int, int);
int fd0_redirected_p(void);
#else
void redirect();
void popredir();
void clearredir();
int copyfd();
int fd0_redirected_p();
#endif
void redirect __P((union node *, int));
void popredir __P((void));
int fd0_redirected_p __P((void));
void clearredir __P((void));
int copyfd __P((int, int));

View File

@ -1,5 +1,4 @@
.\" $NetBSD: sh.1,v 1.14 1995/03/21 09:10:12 cgd Exp $
.\"
.\" $NetBSD: sh.1,v 1.15 1995/05/11 21:30:18 christos Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@ -34,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)sh.1 8.4 (Berkeley) 4/18/94
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
.\"
.na
.TH SH 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: shell.h,v 1.7 1995/03/21 09:10:17 cgd Exp $ */
/* $NetBSD: shell.h,v 1.8 1995/05/11 21:30:22 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)shell.h 8.1 (Berkeley) 5/31/93
* @(#)shell.h 8.2 (Berkeley) 5/4/95
*/
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: show.c,v 1.10 1995/03/21 09:10:22 cgd Exp $ */
/* $NetBSD: show.c,v 1.11 1995/05/11 21:30:24 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,26 +38,35 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)show.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: show.c,v 1.10 1995/03/21 09:10:22 cgd Exp $";
static char rcsid[] = "$NetBSD: show.c,v 1.11 1995/05/11 21:30:24 christos Exp $";
#endif
#endif /* not lint */
#include <stdio.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "shell.h"
#include "parser.h"
#include "nodes.h"
#include "mystring.h"
#include "extern.h"
#include "show.h"
#ifdef DEBUG
static void shtree(), shcmd(), sharg(), indent();
static void shtree __P((union node *, int, char *, FILE*));
static void shcmd __P((union node *, FILE *));
static void sharg __P((union node *, FILE *));
static void indent __P((int, char *, FILE *));
static void trstring __P((char *));
int
void
showtree(n)
union node *n;
{
@ -125,7 +134,7 @@ static void
shcmd(cmd, fp)
union node *cmd;
FILE *fp;
{
{
union node *np;
int first;
char *s;
@ -147,6 +156,7 @@ shcmd(cmd, fp)
case NTOFD: s = ">&"; dftfd = 1; break;
case NFROM: s = "<"; dftfd = 0; break;
case NFROMFD: s = "<&"; dftfd = 0; break;
default: s = "*error*"; dftfd = 0; break;
}
if (np->nfile.fd != dftfd)
fprintf(fp, "%d", np->nfile.fd);
@ -294,16 +304,29 @@ trputc(c)
#endif
}
trace(fmt, a1, a2, a3, a4, a5, a6, a7, a8)
char *fmt;
{
void
#if __STDC__
trace(const char *fmt, ...)
#else
trace(va_alist)
va_dcl
#endif
{
#ifdef DEBUG
if (tracefile == NULL)
return;
fprintf(tracefile, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
if (strchr(fmt, '\n'))
fflush(tracefile);
va_list va;
#if __STDC__
va_start(va, fmt);
#else
char *fmt;
va_start(va);
fmt = va_arg(va, char *);
#endif
if (tracefile != NULL) {
(void) vfprintf(tracefile, fmt, va);
if (strchr(fmt, '\n'))
(void) fflush(tracefile);
}
va_end(va);
#endif
}
@ -387,22 +410,26 @@ trargs(ap)
void
opentrace() {
char s[100];
char *p;
char *getenv();
#ifdef O_APPEND
int flags;
#endif
#ifdef DEBUG
if (!debug)
return;
#ifdef not_this_way
if ((p = getenv("HOME")) == NULL) {
if (geteuid() == 0)
p = "/";
else
p = "/tmp";
{
char *p;
if ((p = getenv("HOME")) == NULL) {
if (geteuid() == 0)
p = "/";
else
p = "/tmp";
}
scopy(p, s);
strcat(s, "/trace");
}
scopy(p, s);
strcat(s, "/trace");
#else
scopy("./trace", s);
#endif /* not_this_way */

43
bin/sh/show.h Normal file
View File

@ -0,0 +1,43 @@
/* $NetBSD: show.h,v 1.1 1995/05/11 21:30:27 christos Exp $ */
/*-
* Copyright (c) 1995
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)show.h 1.1 (Berkeley) 5/4/95
*/
void showtree __P((union node *));
void trputc __P((int));
void trace __P((const char *, ...));
void trputs __P((char *));
void trargs __P((char **));
void opentrace __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.12 1995/03/21 09:10:25 cgd Exp $ */
/* $NetBSD: trap.c,v 1.13 1995/05/11 21:30:28 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,17 +38,22 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)trap.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)trap.c 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: trap.c,v 1.12 1995/03/21 09:10:25 cgd Exp $";
static char rcsid[] = "$NetBSD: trap.c,v 1.13 1995/05/11 21:30:28 christos Exp $";
#endif
#endif /* not lint */
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include "shell.h"
#include "main.h"
#include "nodes.h" /* for other headers */
#include "eval.h"
#include "jobs.h"
#include "show.h"
#include "options.h"
#include "syntax.h"
#include "output.h"
@ -56,8 +61,6 @@ static char rcsid[] = "$NetBSD: trap.c,v 1.12 1995/03/21 09:10:25 cgd Exp $";
#include "error.h"
#include "trap.h"
#include "mystring.h"
#include <signal.h>
#include <unistd.h>
/*
@ -156,7 +159,7 @@ setsignal(signo)
int signo;
{
int action;
sig_t sigact;
sig_t sigact = SIG_DFL;
char *t;
extern void onsig();
extern sig_t getsigaction();
@ -235,7 +238,7 @@ getsigaction(signo)
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
error("Sigaction system call failed");
return sa.sa_handler;
return (sig_t) sa.sa_handler;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.h,v 1.8 1995/03/21 09:10:29 cgd Exp $ */
/* $NetBSD: trap.h,v 1.9 1995/05/11 21:30:32 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,23 +35,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)trap.h 8.1 (Berkeley) 5/31/93
* @(#)trap.h 8.2 (Berkeley) 5/4/95
*/
extern int pendingsigs;
#ifdef __STDC__
void clear_traps(void);
long setsignal(int);
void ignoresig(int);
void dotrap(void);
void setinteractive(int);
void exitshell(int);
#else
void clear_traps();
long setsignal();
void ignoresig();
void dotrap();
void setinteractive();
void exitshell();
#endif
int trapcmd __P((int, char **));
void clear_traps __P((void));
long setsignal __P((int));
sig_t getsigaction __P((int));
void ignoresig __P((int));
void onsig __P((int));
void dotrap __P((void));
void setinteractive __P((int));
void exitshell __P((int));

View File

@ -1,167 +0,0 @@
/* $NetBSD: ulimit.c,v 1.3 1995/04/11 03:17:45 christos Exp $ */
/*
* ulimit builtin
*
* This code, originally by Doug Gwyn, Doug Kingston, Eric Gisin, and
* Michael Rendell was ripped from pdksh 5.0.8 and hacked for use with
* ash by J.T. Conklin.
*
* Public domain.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "shell.h"
#include "options.h"
#include "output.h"
struct limits {
const char *name;
int cmd;
int factor; /* multiply by to get rlim_{cur,max} values */
char option;
};
static const struct limits limits[] = {
#ifdef RLIMIT_CPU
{ "time(seconds)", RLIMIT_CPU, 1, 't' },
#endif
#ifdef RLIMIT_FSIZE
{ "file(blocks)", RLIMIT_FSIZE, 512, 'f' },
#endif
#ifdef RLIMIT_DATA
{ "data(kbytes)", RLIMIT_DATA, 1024, 'd' },
#endif
#ifdef RLIMIT_STACK
{ "stack(kbytes)", RLIMIT_STACK, 1024, 's' },
#endif
#ifdef RLIMIT_CORE
{ "coredump(blocks)", RLIMIT_CORE, 512, 'c' },
#endif
#ifdef RLIMIT_RSS
{ "memory(kbytes)", RLIMIT_RSS, 1024, 'm' },
#endif
#ifdef RLIMIT_MEMLOCK
{ "locked memory(kbytes)", RLIMIT_MEMLOCK, 1024, 'l' },
#endif
#ifdef RLIMIT_NPROC
{ "process(processes)", RLIMIT_NPROC, 1, 'p' },
#endif
#ifdef RLIMIT_NOFILE
{ "nofiles(descriptors)", RLIMIT_NOFILE, 1, 'n' },
#endif
#ifdef RLIMIT_VMEM
{ "vmemory(kbytes)", RLIMIT_VMEM, 1024, 'v' },
#endif
#ifdef RLIMIT_SWAP
{ "swap(kbytes)", RLIMIT_SWAP, 1024, 'w' },
#endif
{ (char *) 0, 0, 0, '\0' }
};
int
ulimitcmd(argc, argv)
int argc;
char **argv;
{
register int c;
quad_t val;
enum { SOFT = 0x1, HARD = 0x2 }
how = SOFT | HARD;
const struct limits *l;
int set, all = 0;
int optc, what;
struct rlimit limit;
what = 'f';
while ((optc = nextopt("HSatfdsmcnpl")) != '\0')
switch (optc) {
case 'H':
how = HARD;
break;
case 'S':
how = SOFT;
break;
case 'a':
all = 1;
break;
default:
what = optc;
}
for (l = limits; l->name && l->option != what; l++)
;
if (!l->name)
error("ulimit: internal error (%c)\n", what);
set = *argptr ? 1 : 0;
if (set) {
char *p = *argptr;
if (all || argptr[1])
error("ulimit: too many arguments\n");
if (strcmp(p, "unlimited") == 0)
val = RLIM_INFINITY;
else {
val = (quad_t) 0;
while ((c = *p++) >= '0' && c <= '9')
{
val = (val * 10) + (long)(c - '0');
if (val < (quad_t) 0)
break;
}
if (c)
error("ulimit: bad number\n");
val *= l->factor;
}
}
if (all) {
for (l = limits; l->name; l++) {
getrlimit(l->cmd, &limit);
if (how & SOFT)
val = limit.rlim_cur;
else if (how & HARD)
val = limit.rlim_max;
out1fmt("%-20s ", l->name);
if (val == RLIM_INFINITY)
out1fmt("unlimited\n");
else
{
val /= l->factor;
out1fmt("%ld\n", (long) val);
}
}
return 0;
}
getrlimit(l->cmd, &limit);
if (set) {
if (how & SOFT)
limit.rlim_cur = val;
if (how & HARD)
limit.rlim_max = val;
if (setrlimit(l->cmd, &limit) < 0)
error("ulimit: bad limit\n");
} else {
if (how & SOFT)
val = limit.rlim_cur;
else if (how & HARD)
val = limit.rlim_max;
}
if (!set) {
if (val == RLIM_INFINITY)
out1fmt("unlimited\n");
else
{
val /= l->factor;
out1fmt("%ld\n", (long) val);
}
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.12 1995/03/21 09:10:35 cgd Exp $ */
/* $NetBSD: var.c,v 1.13 1995/05/11 21:30:39 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,18 +38,19 @@
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
#else
static char rcsid[] = "$NetBSD: var.c,v 1.12 1995/03/21 09:10:35 cgd Exp $";
static char rcsid[] = "$NetBSD: var.c,v 1.13 1995/05/11 21:30:39 christos Exp $";
#endif
#endif /* not lint */
#include <unistd.h>
#include <stdlib.h>
/*
* Shell variables.
*/
#include <unistd.h>
#include "shell.h"
#include "output.h"
#include "expand.h"
@ -63,7 +64,9 @@ static char rcsid[] = "$NetBSD: var.c,v 1.12 1995/03/21 09:10:35 cgd Exp $";
#include "memalloc.h"
#include "error.h"
#include "mystring.h"
#include "extern.h"
#ifndef NO_HISTORY
#include "myhistedit.h"
#endif
#define VTABSIZE 39
@ -332,8 +335,8 @@ bltinlookup(name, doall)
}
for (v = *hashvar(name) ; v ; v = v->next) {
if (varequal(v->text, name)) {
if (v->flags & VUNSET
|| ! doall && (v->flags & VEXPORT) == 0)
if ((v->flags & VUNSET)
|| (!doall && (v->flags & VEXPORT) == 0))
return NULL;
return strchr(v->text, '=') + 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.h,v 1.8 1995/03/21 09:10:38 cgd Exp $ */
/* $NetBSD: var.h,v 1.9 1995/05/11 21:30:44 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)var.h 8.1 (Berkeley) 5/31/93
* @(#)var.h 8.2 (Berkeley) 5/4/95
*/
/*
@ -102,30 +102,19 @@ extern struct var vterm;
#endif
#define mpathset() ((vmpath.flags & VUNSET) == 0)
#ifdef __STDC__
void initvar();
void setvar(char *, char *, int);
void setvareq(char *, int);
void initvar __P((void));
void setvar __P((char *, char *, int));
void setvareq __P((char *, int));
struct strlist;
void listsetvar(struct strlist *);
char *lookupvar(char *);
char *bltinlookup(char *, int);
char **environment();
int showvarscmd(int, char **);
void mklocal(char *);
void poplocalvars(void);
int unsetcmd(int, char **);
#else
void initvar();
void setvar();
void setvareq();
void listsetvar();
char *lookupvar();
char *bltinlookup();
char **environment();
int showvarscmd();
void mklocal();
void poplocalvars();
int unsetcmd();
#endif
void listsetvar __P((struct strlist *));
char *lookupvar __P((char *));
char *bltinlookup __P((char *, int));
char **environment __P((void));
void shprocvar __P((void));
int showvarscmd __P((int, char **));
int exportcmd __P((int, char **));
int localcmd __P((int, char **));
void mklocal __P((char *));
void poplocalvars __P((void));
int setvarcmd __P((int, char **));
int unsetcmd __P((int, char **));