Merge in my changes from vangogh, and fix the x=false
; echo $? == 0
bug.
This commit is contained in:
parent
8aa6c376b6
commit
07bae7eddd
@ -1,21 +1,19 @@
|
|||||||
# $NetBSD: Makefile,v 1.19 1995/03/21 09:08:36 cgd Exp $
|
# $NetBSD: Makefile,v 1.20 1995/05/11 21:28:33 christos Exp $
|
||||||
# @(#)Makefile 8.1 (Berkeley) 6/8/93
|
# @(#)Makefile 8.4 (Berkeley) 5/5/95
|
||||||
|
|
||||||
PROG= sh
|
PROG= sh
|
||||||
SRCS= alias.c builtins.c cd.c echo.c error.c eval.c exec.c expand.c \
|
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 \
|
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 \
|
mystring.c nodes.c options.c parser.c redir.c show.c syntax.c \
|
||||||
syntax.c trap.c output.c ulimit.c var.c
|
trap.c output.c var.c
|
||||||
OBJS+= init.o arith.o arith_lex.o
|
OBJS+= init.o arith.o arith_lex.o
|
||||||
LDADD+= -ll -ledit -ltermcap
|
LDADD+= -ll -ledit -ltermcap
|
||||||
DPADD+= ${LIBL} ${LIBEDIT} ${LIBTERMCAP}
|
|
||||||
LFLAGS= -8 # 8-bit lex scanner for arithmetic
|
LFLAGS= -8 # 8-bit lex scanner for arithmetic
|
||||||
CFLAGS+=-DSHELL -I. -I${.CURDIR}
|
CFLAGS+=-DSHELL -I. -I${.CURDIR}
|
||||||
.PATH: ${.CURDIR}/bltin ${.CURDIR}/../../usr.bin/printf
|
.PATH: ${.CURDIR}/bltin ${.CURDIR}/../../usr.bin/printf
|
||||||
CLEANFILES+=\
|
CLEANFILES+=\
|
||||||
builtins.c builtins.h init.c mkinit mknodes mksyntax \
|
builtins.c builtins.h init.c mkinit mknodes mksyntax \
|
||||||
nodes.c nodes.h syntax.c syntax.h token.def \
|
nodes.c nodes.h printf.o syntax.c syntax.h token.def y.tab.h
|
||||||
y.tab.h
|
|
||||||
|
|
||||||
.depend parser.o: token.def
|
.depend parser.o: token.def
|
||||||
token.def: mktokens
|
token.def: mktokens
|
||||||
|
@ -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
|
# @(#)TOUR 8.1 (Berkeley) 5/31/93
|
||||||
|
|
||||||
NOTE -- This is the original TOUR paper distributed with ash and
|
NOTE -- This is the original TOUR paper distributed with ash and
|
||||||
|
@ -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
|
* Copyright (c) 1993
|
||||||
@ -38,12 +38,13 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "output.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];
|
struct alias *atab[ATABSIZE];
|
||||||
|
|
||||||
|
STATIC void setalias __P((char *, char *));
|
||||||
|
STATIC int unalias __P((char *));
|
||||||
STATIC struct alias **hashalias __P((char *));
|
STATIC struct alias **hashalias __P((char *));
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
@ -215,7 +218,7 @@ aliascmd(argc, argv)
|
|||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
while (n = *++argv) {
|
while ((n = *++argv) != NULL) {
|
||||||
if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */
|
if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */
|
||||||
if ((ap = lookupalias(n, 0)) == NULL) {
|
if ((ap = lookupalias(n, 0)) == NULL) {
|
||||||
outfmt(out2, "alias: %s not found\n", n);
|
outfmt(out2, "alias: %s not found\n", n);
|
||||||
|
@ -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
|
* Copyright (c) 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)alias.h 8.1 (Berkeley) 5/31/93
|
* @(#)alias.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ALIASINUSE 1
|
#define ALIASINUSE 1
|
||||||
@ -47,4 +47,7 @@ struct alias {
|
|||||||
int flag;
|
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
39
bin/sh/arith.h
Normal 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 **));
|
@ -53,7 +53,7 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
|
|||||||
| ARITH_NUM
|
| 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
|
* Copyright (c) 1993
|
||||||
@ -93,9 +93,9 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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;
|
char *arith_buf, *arith_startbuf;
|
||||||
|
|
||||||
|
int
|
||||||
arith(s)
|
arith(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
@ -121,6 +122,7 @@ arith(s)
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
yyerror(s)
|
yyerror(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
@ -134,7 +136,9 @@ yyerror(s)
|
|||||||
/*
|
/*
|
||||||
* The exp(1) builtin.
|
* The exp(1) builtin.
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
expcmd(argc, argv)
|
expcmd(argc, argv)
|
||||||
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -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
|
* Copyright (c) 1993
|
||||||
@ -39,13 +39,15 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
extern yylval;
|
extern yylval;
|
||||||
extern char *arith_buf, *arith_startbuf;
|
extern char *arith_buf, *arith_startbuf;
|
||||||
@ -82,6 +84,7 @@ extern char *arith_buf, *arith_startbuf;
|
|||||||
. { error("arith: syntax error: \"%s\"\n", arith_startbuf); }
|
. { error("arith: syntax error: \"%s\"\n", arith_startbuf); }
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
void
|
||||||
arith_lex_reset() {
|
arith_lex_reset() {
|
||||||
YY_NEW_FILE;
|
YY_NEW_FILE;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh -
|
#!/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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# 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
|
# 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
|
# for bltincmd, which is run when the user does not specify a command, must
|
||||||
# come first.
|
# 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!
|
# NOTE: bltincmd must come first!
|
||||||
|
|
||||||
bltincmd command
|
bltincmd command
|
||||||
|
33
bin/sh/cd.c
33
bin/sh/cd.c
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,14 +38,15 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.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 "output.h"
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "redir.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "extern.h"
|
#include "show.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
|
|
||||||
|
|
||||||
|
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 *curdir; /* current working directory */
|
||||||
char *prevdir; /* previous working directory */
|
char *prevdir; /* previous working directory */
|
||||||
@ -119,6 +112,8 @@ cdcmd(argc, argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
error("can't cd to %s", dest);
|
error("can't cd to %s", dest);
|
||||||
|
/*NOTREACHED*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -177,7 +172,7 @@ top:
|
|||||||
}
|
}
|
||||||
first = 1;
|
first = 1;
|
||||||
while ((q = getcomponent()) != NULL) {
|
while ((q = getcomponent()) != NULL) {
|
||||||
if (q[0] == '\0' || q[0] == '.' && q[1] == '\0')
|
if (q[0] == '\0' || (q[0] == '.' && q[1] == '\0'))
|
||||||
continue;
|
continue;
|
||||||
if (! first)
|
if (! first)
|
||||||
STPUTC('/', p);
|
STPUTC('/', p);
|
||||||
@ -370,7 +365,7 @@ getpwd() {
|
|||||||
pip[1] = -1;
|
pip[1] = -1;
|
||||||
p = buf;
|
p = buf;
|
||||||
while ((i = read(pip[0], p, buf + MAXPWD - p)) > 0
|
while ((i = read(pip[0], p, buf + MAXPWD - p)) > 0
|
||||||
|| i == -1 && errno == EINTR) {
|
|| (i == -1 && errno == EINTR)) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
p += i;
|
p += i;
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
char sccsid[] = "@(#)error.c 8.1 (Berkeley) 5/31/93";
|
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
|
||||||
#else
|
#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
|
||||||
#endif /* not lint */
|
#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 "options.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "show.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifdef __STDC__
|
|
||||||
#include "stdarg.h"
|
|
||||||
#else
|
|
||||||
#include <varargs.h>
|
|
||||||
#endif
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -134,21 +130,23 @@ error2(a, b)
|
|||||||
* formatting. It then raises the error exception.
|
* formatting. It then raises the error exception.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __STDC__
|
#if __STDC__
|
||||||
void
|
void
|
||||||
error(char *msg, ...) {
|
error(char *msg, ...)
|
||||||
#else
|
#else
|
||||||
void
|
void
|
||||||
error(va_alist)
|
error(va_alist)
|
||||||
va_dcl
|
va_dcl
|
||||||
{
|
#endif
|
||||||
|
{
|
||||||
|
#if !__STDC__
|
||||||
char *msg;
|
char *msg;
|
||||||
#endif
|
#endif
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
CLEAR_PENDING_INT;
|
CLEAR_PENDING_INT;
|
||||||
INTOFF;
|
INTOFF;
|
||||||
#ifdef __STDC__
|
|
||||||
|
#if __STDC__
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
#else
|
#else
|
||||||
va_start(ap);
|
va_start(ap);
|
||||||
@ -187,55 +185,57 @@ struct errname {
|
|||||||
#define ALL (E_OPEN|E_CREAT|E_EXEC)
|
#define ALL (E_OPEN|E_CREAT|E_EXEC)
|
||||||
|
|
||||||
STATIC const struct errname errormsg[] = {
|
STATIC const struct errname errormsg[] = {
|
||||||
EINTR, ALL, "interrupted",
|
{ EINTR, ALL, "interrupted" },
|
||||||
EACCES, ALL, "permission denied",
|
{ EACCES, ALL, "permission denied" },
|
||||||
EIO, ALL, "I/O error",
|
{ EIO, ALL, "I/O error" },
|
||||||
ENOENT, E_OPEN, "no such file",
|
{ ENOENT, E_OPEN, "no such file" },
|
||||||
ENOENT, E_CREAT, "directory nonexistent",
|
{ ENOENT, E_CREAT,"directory nonexistent" },
|
||||||
ENOENT, E_EXEC, "not found",
|
{ ENOENT, E_EXEC, "not found" },
|
||||||
ENOTDIR, E_OPEN, "no such file",
|
{ ENOTDIR, E_OPEN, "no such file" },
|
||||||
ENOTDIR, E_CREAT, "directory nonexistent",
|
{ ENOTDIR, E_CREAT,"directory nonexistent" },
|
||||||
ENOTDIR, E_EXEC, "not found",
|
{ ENOTDIR, E_EXEC, "not found" },
|
||||||
EISDIR, ALL, "is a directory",
|
{ EISDIR, ALL, "is a directory" },
|
||||||
/* EMFILE, ALL, "too many open files", */
|
#ifdef notdef
|
||||||
ENFILE, ALL, "file table overflow",
|
{ EMFILE, ALL, "too many open files" },
|
||||||
ENOSPC, ALL, "file system full",
|
#endif
|
||||||
|
{ ENFILE, ALL, "file table overflow" },
|
||||||
|
{ ENOSPC, ALL, "file system full" },
|
||||||
#ifdef EDQUOT
|
#ifdef EDQUOT
|
||||||
EDQUOT, ALL, "disk quota exceeded",
|
{ EDQUOT, ALL, "disk quota exceeded" },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENOSR
|
#ifdef ENOSR
|
||||||
ENOSR, ALL, "no streams resources",
|
{ ENOSR, ALL, "no streams resources" },
|
||||||
#endif
|
#endif
|
||||||
ENXIO, ALL, "no such device or address",
|
{ ENXIO, ALL, "no such device or address" },
|
||||||
EROFS, ALL, "read-only file system",
|
{ EROFS, ALL, "read-only file system" },
|
||||||
ETXTBSY, ALL, "text busy",
|
{ ETXTBSY, ALL, "text busy" },
|
||||||
#ifdef SYSV
|
#ifdef SYSV
|
||||||
EAGAIN, E_EXEC, "not enough memory",
|
{ EAGAIN, E_EXEC, "not enough memory" },
|
||||||
#endif
|
#endif
|
||||||
ENOMEM, ALL, "not enough memory",
|
{ ENOMEM, ALL, "not enough memory" },
|
||||||
#ifdef ENOLINK
|
#ifdef ENOLINK
|
||||||
ENOLINK, ALL, "remote access failed",
|
{ ENOLINK, ALL, "remote access failed" },
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMULTIHOP
|
#ifdef EMULTIHOP
|
||||||
EMULTIHOP, ALL, "remote access failed",
|
{ EMULTIHOP, ALL, "remote access failed" },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ECOMM
|
#ifdef ECOMM
|
||||||
ECOMM, ALL, "remote access failed",
|
{ ECOMM, ALL, "remote access failed" },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ESTALE
|
#ifdef ESTALE
|
||||||
ESTALE, ALL, "remote access failed",
|
{ ESTALE, ALL, "remote access failed" },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ETIMEDOUT
|
#ifdef ETIMEDOUT
|
||||||
ETIMEDOUT, ALL, "remote access failed",
|
{ ETIMEDOUT, ALL, "remote access failed" },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ELOOP
|
#ifdef ELOOP
|
||||||
ELOOP, ALL, "symbolic link loop",
|
{ ELOOP, ALL, "symbolic link loop" },
|
||||||
#endif
|
#endif
|
||||||
E2BIG, E_EXEC, "argument list too long",
|
{ E2BIG, E_EXEC, "argument list too long" },
|
||||||
#ifdef ELIBACC
|
#ifdef ELIBACC
|
||||||
ELIBACC, E_EXEC, "shared library missing",
|
{ ELIBACC, E_EXEC, "shared library missing" },
|
||||||
#endif
|
#endif
|
||||||
0, 0, NULL
|
{ 0, 0, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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 */
|
extern char *commandname; /* name of command--printed on error */
|
||||||
|
|
||||||
#define INTOFF suppressint++
|
#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 FORCEINTON {suppressint = 0; if (intpending) onint();}
|
||||||
#define CLEAR_PENDING_INT intpending = 0
|
#define CLEAR_PENDING_INT intpending = 0
|
||||||
#define int_pending() intpending
|
#define int_pending() intpending
|
||||||
|
|
||||||
#ifdef __STDC__
|
void exraise __P((int));
|
||||||
void exraise(int);
|
void onint __P((void));
|
||||||
void onint(void);
|
void error2 __P((char *, char *));
|
||||||
void error2(char *, char *);
|
void error __P((char *, ...));
|
||||||
void error(char *, ...);
|
char *errmsg __P((int, int));
|
||||||
char *errmsg(int, int);
|
|
||||||
#else
|
|
||||||
void exraise();
|
|
||||||
void onint();
|
|
||||||
void error2();
|
|
||||||
void error();
|
|
||||||
char *errmsg();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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
|
* Copyright (c) 1993
|
||||||
@ -38,12 +38,15 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Evaluate a command.
|
* 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 "var.h"
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "show.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#ifndef NO_HISTORY
|
#ifndef NO_HISTORY
|
||||||
#include "myhistedit.h"
|
#include "myhistedit.h"
|
||||||
#endif
|
#endif
|
||||||
#include "extern.h"
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* flags in argument to evaltree */
|
/* flags in argument to evaltree */
|
||||||
@ -96,26 +97,14 @@ struct strlist *cmdenviron;
|
|||||||
int exitstatus; /* exit status of last command */
|
int exitstatus; /* exit status of last command */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void evalloop __P((union node *));
|
||||||
STATIC void evalloop(union node *);
|
STATIC void evalfor __P((union node *));
|
||||||
STATIC void evalfor(union node *);
|
STATIC void evalcase __P((union node *, int));
|
||||||
STATIC void evalcase(union node *, int);
|
STATIC void evalsubshell __P((union node *, int));
|
||||||
STATIC void evalsubshell(union node *, int);
|
STATIC void expredir __P((union node *));
|
||||||
STATIC void expredir(union node *);
|
STATIC void evalpipe __P((union node *));
|
||||||
STATIC void evalpipe(union node *);
|
STATIC void evalcommand __P((union node *, int, struct backcmd *));
|
||||||
STATIC void evalcommand(union node *, int, struct backcmd *);
|
STATIC void prehash __P((union node *));
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -615,6 +604,13 @@ evalcommand(cmd, flags, backcmd)
|
|||||||
struct localvar *volatile savelocalvars;
|
struct localvar *volatile savelocalvars;
|
||||||
volatile int e;
|
volatile int e;
|
||||||
char *lastarg;
|
char *lastarg;
|
||||||
|
#if __GNUC__
|
||||||
|
/* Avoid longjmp clobbering */
|
||||||
|
(void) &argv;
|
||||||
|
(void) &argc;
|
||||||
|
(void) &lastarg;
|
||||||
|
(void) &flags;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* First expand the arguments. */
|
/* First expand the arguments. */
|
||||||
TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
|
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. */
|
/* Fork off a child process if necessary. */
|
||||||
if (cmd->ncmd.backgnd
|
if (cmd->ncmd.backgnd
|
||||||
|| cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0
|
|| (cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0)
|
||||||
|| (flags & EV_BACKCMD) != 0
|
|| ((flags & EV_BACKCMD) != 0
|
||||||
&& (cmdentry.cmdtype != CMDBUILTIN
|
&& (cmdentry.cmdtype != CMDBUILTIN
|
||||||
|| cmdentry.u.index == DOTCMD
|
|| cmdentry.u.index == DOTCMD
|
||||||
|| cmdentry.u.index == EVALCMD)) {
|
|| cmdentry.u.index == EVALCMD))) {
|
||||||
jp = makejob(cmd, 1);
|
jp = makejob(cmd, 1);
|
||||||
mode = cmd->ncmd.backgnd;
|
mode = cmd->ncmd.backgnd;
|
||||||
if (flags & EV_BACKCMD) {
|
if (flags & EV_BACKCMD) {
|
||||||
@ -894,7 +890,8 @@ bltincmd(argc, argv)
|
|||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
listsetvar(cmdenviron);
|
listsetvar(cmdenviron);
|
||||||
return 0;
|
/* Preserve the exitstatus as POSIX.2 mandates */
|
||||||
|
return exitstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)eval.h 8.1 (Berkeley) 5/31/93
|
* @(#)eval.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern char *commandname; /* currently executing command */
|
extern char *commandname; /* currently executing command */
|
||||||
@ -50,17 +50,17 @@ struct backcmd { /* result of evalbackcmd */
|
|||||||
struct job *jp; /* job structure for command */
|
struct job *jp; /* job structure for command */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int evalcmd __P((int, char **));
|
||||||
#ifdef __STDC__
|
void evalstring __P((char *));
|
||||||
void evalstring(char *);
|
|
||||||
union node; /* BLETCH for ansi C */
|
union node; /* BLETCH for ansi C */
|
||||||
void evaltree(union node *, int);
|
void evaltree __P((union node *, int));
|
||||||
void evalbackcmd(union node *, struct backcmd *);
|
void evalbackcmd __P((union node *, struct backcmd *));
|
||||||
#else
|
int bltincmd __P((int, char **));
|
||||||
void evalstring();
|
int breakcmd __P((int, char **));
|
||||||
void evaltree();
|
int returncmd __P((int, char **));
|
||||||
void evalbackcmd();
|
int falsecmd __P((int, char **));
|
||||||
#endif
|
int truecmd __P((int, char **));
|
||||||
|
int execcmd __P((int, char **));
|
||||||
|
|
||||||
/* in_function returns nonzero if we are currently evaluating a function */
|
/* in_function returns nonzero if we are currently evaluating a function */
|
||||||
#define in_function() funcnest
|
#define in_function() funcnest
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,12 +38,19 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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.
|
* 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
|
* 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 "error.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
|
#include "show.h"
|
||||||
#include "jobs.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 */
|
#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 */
|
STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void tryexec __P((char *, char **, char **));
|
||||||
STATIC void tryexec(char *, char **, char **);
|
STATIC void execinterp __P((char **, char **));
|
||||||
STATIC void execinterp(char **, char **);
|
STATIC void printentry __P((struct tblentry *, int));
|
||||||
STATIC void printentry(struct tblentry *, int);
|
STATIC void clearcmdentry __P((int));
|
||||||
STATIC void clearcmdentry(int);
|
STATIC struct tblentry *cmdlookup __P((char *, int));
|
||||||
STATIC struct tblentry *cmdlookup(char *, int);
|
STATIC void delete_cmd_entry __P((void));
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -153,7 +147,9 @@ tryexec(cmd, argv, envp)
|
|||||||
char **envp;
|
char **envp;
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
|
#ifndef BSD
|
||||||
char *p;
|
char *p;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SYSV
|
#ifdef SYSV
|
||||||
do {
|
do {
|
||||||
@ -345,7 +341,7 @@ hashcmd(argc, argv)
|
|||||||
while ((name = *argptr) != NULL) {
|
while ((name = *argptr) != NULL) {
|
||||||
if ((cmdp = cmdlookup(name, 0)) != NULL
|
if ((cmdp = cmdlookup(name, 0)) != NULL
|
||||||
&& (cmdp->cmdtype == CMDNORMAL
|
&& (cmdp->cmdtype == CMDNORMAL
|
||||||
|| cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))
|
|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
|
||||||
delete_cmd_entry();
|
delete_cmd_entry();
|
||||||
find_command(name, &entry, 1);
|
find_command(name, &entry, 1);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@ -571,7 +567,7 @@ hashcd() {
|
|||||||
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
|
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
|
||||||
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
|
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
|
||||||
if (cmdp->cmdtype == CMDNORMAL
|
if (cmdp->cmdtype == CMDNORMAL
|
||||||
|| cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)
|
|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))
|
||||||
cmdp->rehash = 1;
|
cmdp->rehash = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -602,8 +598,8 @@ changepath(newval)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
if (*old != *new) {
|
if (*old != *new) {
|
||||||
firstchange = index;
|
firstchange = index;
|
||||||
if (*old == '\0' && *new == ':'
|
if ((*old == '\0' && *new == ':')
|
||||||
|| *old == ':' && *new == '\0')
|
|| (*old == ':' && *new == '\0'))
|
||||||
firstchange++;
|
firstchange++;
|
||||||
old = new; /* ignore subsequent differences */
|
old = new; /* ignore subsequent differences */
|
||||||
}
|
}
|
||||||
@ -612,8 +608,6 @@ changepath(newval)
|
|||||||
if (*new == '%' && bltin < 0 && prefix("builtin", new + 1))
|
if (*new == '%' && bltin < 0 && prefix("builtin", new + 1))
|
||||||
bltin = index;
|
bltin = index;
|
||||||
if (*new == ':') {
|
if (*new == ':') {
|
||||||
char c = *(new+1);
|
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
new++, old++;
|
new++, old++;
|
||||||
@ -644,8 +638,10 @@ clearcmdentry(firstchange)
|
|||||||
for (tblp = cmdtable ; tblp < &cmdtable[CMDTABLESIZE] ; tblp++) {
|
for (tblp = cmdtable ; tblp < &cmdtable[CMDTABLESIZE] ; tblp++) {
|
||||||
pp = tblp;
|
pp = tblp;
|
||||||
while ((cmdp = *pp) != NULL) {
|
while ((cmdp = *pp) != NULL) {
|
||||||
if (cmdp->cmdtype == CMDNORMAL && cmdp->param.index >= firstchange
|
if ((cmdp->cmdtype == CMDNORMAL &&
|
||||||
|| cmdp->cmdtype == CMDBUILTIN && builtinloc >= firstchange) {
|
cmdp->param.index >= firstchange)
|
||||||
|
|| (cmdp->cmdtype == CMDBUILTIN &&
|
||||||
|
builtinloc >= firstchange)) {
|
||||||
*pp = cmdp->next;
|
*pp = cmdp->next;
|
||||||
ckfree(cmdp);
|
ckfree(cmdp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)exec.h 8.1 (Berkeley) 5/31/93
|
* @(#)exec.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* values of cmdtype */
|
/* values of cmdtype */
|
||||||
@ -56,22 +56,15 @@ struct cmdentry {
|
|||||||
|
|
||||||
extern char *pathopt; /* set by padvance */
|
extern char *pathopt; /* set by padvance */
|
||||||
|
|
||||||
#ifdef __STDC__
|
void shellexec __P((char **, char **, char *, int));
|
||||||
void shellexec(char **, char **, char *, int);
|
char *padvance __P((char **, char *));
|
||||||
char *padvance(char **, char *);
|
int hashcmd __P((int, char **));
|
||||||
void find_command(char *, struct cmdentry *, int);
|
void find_command __P((char *, struct cmdentry *, int));
|
||||||
int find_builtin(char *);
|
int find_builtin __P((char *));
|
||||||
void hashcd(void);
|
void hashcd __P((void));
|
||||||
void changepath(char *);
|
void changepath __P((char *));
|
||||||
void defun(char *, union node *);
|
void deletefuncs __P((void));
|
||||||
int unsetfunc(char *);
|
void getcmdentry __P((char *, struct cmdentry *));
|
||||||
#else
|
void addcmdentry __P((char *, struct cmdentry *));
|
||||||
void shellexec();
|
void defun __P((char *, union node *));
|
||||||
char *padvance();
|
int unsetfunc __P((char *));
|
||||||
void find_command();
|
|
||||||
int find_builtin();
|
|
||||||
void hashcd();
|
|
||||||
void changepath();
|
|
||||||
void defun();
|
|
||||||
int unsetfunc();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,12 +38,21 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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
|
* Routines to expand arguments to commands. We have to deal with
|
||||||
* backquotes, shell variables, and file metacharacters.
|
* 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 "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include <sys/types.h>
|
#include "arith.h"
|
||||||
#include <sys/time.h>
|
#include "show.h"
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure specifying which parts of the string should be searched
|
* 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 ifsregion *ifslastp; /* last struct in list */
|
||||||
struct arglist exparg; /* holds expanded arg list */
|
struct arglist exparg; /* holds expanded arg list */
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void argstr __P((char *, int));
|
||||||
STATIC void argstr(char *, int);
|
STATIC char *exptilde __P((char *, int));
|
||||||
STATIC void expbackq(union node *, int, int);
|
STATIC void expbackq __P((union node *, int, int));
|
||||||
STATIC int subevalvar(char *, char *, int, int, int);
|
STATIC int subevalvar __P((char *, char *, int, int, int));
|
||||||
STATIC char *evalvar(char *, int);
|
STATIC char *evalvar __P((char *, int));
|
||||||
STATIC int varisset(int);
|
STATIC int varisset __P((int));
|
||||||
STATIC void varvalue(int, int, int);
|
STATIC void varvalue __P((int, int, int));
|
||||||
STATIC void recordregion(int, int, int);
|
STATIC void recordregion __P((int, int, int));
|
||||||
STATIC void ifsbreakup(char *, struct arglist *);
|
STATIC void ifsbreakup __P((char *, struct arglist *));
|
||||||
STATIC void expandmeta(struct strlist *, int);
|
STATIC void expandmeta __P((struct strlist *, int));
|
||||||
STATIC void expmeta(char *, char *);
|
STATIC void expmeta __P((char *, char *));
|
||||||
STATIC void expari(int);
|
STATIC void addfname __P((char *));
|
||||||
STATIC void addfname(char *);
|
STATIC struct strlist *expsort __P((struct strlist *));
|
||||||
STATIC struct strlist *expsort(struct strlist *);
|
STATIC struct strlist *msort __P((struct strlist *, int));
|
||||||
STATIC struct strlist *msort(struct strlist *, int);
|
STATIC int pmatch __P((char *, char *));
|
||||||
STATIC int pmatch(char *, char *);
|
STATIC char *cvtnum __P((int, 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
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Expand shell variables and backquotes inside a here document.
|
* Expand shell variables and backquotes inside a here document.
|
||||||
@ -277,7 +260,7 @@ exptilde(p, flag)
|
|||||||
char *home;
|
char *home;
|
||||||
int quotes = flag & (EXP_FULL | EXP_CASE);
|
int quotes = flag & (EXP_FULL | EXP_CASE);
|
||||||
|
|
||||||
while (c = *p) {
|
while ((c = *p) != '\0') {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case CTLESC:
|
case CTLESC:
|
||||||
return (startp);
|
return (startp);
|
||||||
@ -303,7 +286,7 @@ done:
|
|||||||
if (*home == '\0')
|
if (*home == '\0')
|
||||||
goto lose;
|
goto lose;
|
||||||
*p = c;
|
*p = c;
|
||||||
while (c = *home++) {
|
while ((c = *home++) != '\0') {
|
||||||
if (quotes && SQSYNTAX[c] == CCTL)
|
if (quotes && SQSYNTAX[c] == CCTL)
|
||||||
STPUTC(CTLESC, expdest);
|
STPUTC(CTLESC, expdest);
|
||||||
STPUTC(c, expdest);
|
STPUTC(c, expdest);
|
||||||
@ -571,7 +554,7 @@ again: /* jump here after setting a variable with ${var=text} */
|
|||||||
val = NULL;
|
val = NULL;
|
||||||
} else {
|
} else {
|
||||||
val = lookupvar(var);
|
val = lookupvar(var);
|
||||||
if (val == NULL || (varflags & VSNUL) && val[0] == '\0') {
|
if (val == NULL || ((varflags & VSNUL) && val[0] == '\0')) {
|
||||||
val = NULL;
|
val = NULL;
|
||||||
set = 0;
|
set = 0;
|
||||||
} else
|
} else
|
||||||
@ -1055,7 +1038,7 @@ expmeta(enddir, name)
|
|||||||
*endname++ = '\0';
|
*endname++ = '\0';
|
||||||
}
|
}
|
||||||
matchdot = 0;
|
matchdot = 0;
|
||||||
if (start[0] == '.' || start[0] == CTLESC && start[1] == '.')
|
if (start[0] == '.' || (start[0] == CTLESC && start[1] == '.'))
|
||||||
matchdot++;
|
matchdot++;
|
||||||
while (! int_pending() && (dp = readdir(dirp)) != NULL) {
|
while (! int_pending() && (dp = readdir(dirp)) != NULL) {
|
||||||
if (dp->d_name[0] == '.' && ! matchdot)
|
if (dp->d_name[0] == '.' && ! matchdot)
|
||||||
@ -1066,7 +1049,9 @@ expmeta(enddir, name)
|
|||||||
addfname(expdir);
|
addfname(expdir);
|
||||||
} else {
|
} else {
|
||||||
char *q;
|
char *q;
|
||||||
for (p = enddir, q = dp->d_name ; *p++ = *q++ ;);
|
for (p = enddir, q = dp->d_name;
|
||||||
|
(*p++ = *q++) != '\0';)
|
||||||
|
continue;
|
||||||
p[-1] = '/';
|
p[-1] = '/';
|
||||||
expmeta(p, endname);
|
expmeta(p, endname);
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)expand.h 8.1 (Berkeley) 5/31/93
|
* @(#)expand.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct strlist {
|
struct strlist {
|
||||||
@ -59,17 +59,10 @@ struct arglist {
|
|||||||
#define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */
|
#define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
|
||||||
union node;
|
union node;
|
||||||
void expandarg(union node *, struct arglist *, int);
|
void expandhere __P((union node *, int));
|
||||||
void expandhere(union node *, int);
|
void expandarg __P((union node *, struct arglist *, int));
|
||||||
int patmatch(char *, char *);
|
void expari __P((int));
|
||||||
void rmescapes(char *);
|
int patmatch __P((char *, char *));
|
||||||
int casematch(union node *, char *);
|
void rmescapes __P((char *));
|
||||||
#else
|
int casematch __P((union node *, char *));
|
||||||
void expandarg();
|
|
||||||
void expandhere();
|
|
||||||
int patmatch();
|
|
||||||
void rmescapes();
|
|
||||||
int casematch();
|
|
||||||
#endif
|
|
||||||
|
@ -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 *));
|
|
||||||
|
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)cmv 8.1 (Berkeley) 5/31/93
|
# @(#)cmv 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
# Conditional move--don't replace an existing file.
|
# Conditional move--don't replace an existing 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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)dirs 8.1 (Berkeley) 5/31/93
|
# @(#)dirs 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
# pushd, popd, and dirs --- written by Chris Bertin
|
# pushd, popd, and dirs --- written by Chris Bertin
|
||||||
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
|
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# 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.
|
# Convert job names to process ids and then run /bin/kill.
|
||||||
|
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)login 8.1 (Berkeley) 5/31/93
|
# @(#)login 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
# replaces the login builtin in the BSD shell
|
# replaces the login builtin in the BSD shell
|
||||||
login () exec login "$@"
|
login () exec login "$@"
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)newgrp 8.1 (Berkeley) 5/31/93
|
# @(#)newgrp 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
newgrp() exec newgrp "$@"
|
newgrp() exec newgrp "$@"
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)popd 8.1 (Berkeley) 5/31/93
|
# @(#)popd 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
# pushd, popd, and dirs --- written by Chris Bertin
|
# pushd, popd, and dirs --- written by Chris Bertin
|
||||||
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
|
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)pushd 8.1 (Berkeley) 5/31/93
|
# @(#)pushd 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
# pushd, popd, and dirs --- written by Chris Bertin
|
# pushd, popd, and dirs --- written by Chris Bertin
|
||||||
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
|
# Pixel Computer Inc. ...!wjh12!pixel!pixutl!chris
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)suspend 8.1 (Berkeley) 5/31/93
|
# @(#)suspend 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
suspend() {
|
suspend() {
|
||||||
local -
|
local -
|
||||||
|
@ -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
|
* Copyright (c) 1993
|
||||||
@ -38,31 +38,33 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
|
||||||
* Editline and history functions (and glue).
|
|
||||||
*/
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
/*
|
||||||
|
* Editline and history functions (and glue).
|
||||||
|
*/
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "var.h"
|
#include "var.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "main.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
|
#ifndef NO_HISTORY
|
||||||
|
#include "myhistedit.h"
|
||||||
|
#endif
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "histedit.h"
|
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
#include "extern.h"
|
|
||||||
|
|
||||||
#define MAXHISTLOOPS 4 /* max recursions through fc */
|
#define MAXHISTLOOPS 4 /* max recursions through fc */
|
||||||
#define DEFEDITOR "ed" /* default editor *should* be $EDITOR */
|
#define DEFEDITOR "ed" /* default editor *should* be $EDITOR */
|
||||||
@ -73,8 +75,6 @@ int displayhist;
|
|||||||
static FILE *el_in, *el_out;
|
static FILE *el_in, *el_out;
|
||||||
|
|
||||||
STATIC char *fc_replace __P((const char *, char *, char *));
|
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
|
* Set history and editing status. Called whenever the status may
|
||||||
@ -149,7 +149,8 @@ bad:
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sethistsize() {
|
sethistsize()
|
||||||
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
int histsize;
|
int histsize;
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ sethistsize() {
|
|||||||
int
|
int
|
||||||
histcmd(argc, argv)
|
histcmd(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char **argv;
|
||||||
{
|
{
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind, optopt, optreset;
|
extern int optind, optopt, optreset;
|
||||||
@ -186,6 +187,21 @@ histcmd(argc, argv)
|
|||||||
struct jmploc *volatile savehandler;
|
struct jmploc *volatile savehandler;
|
||||||
char editfile[MAXPATHLEN + 1];
|
char editfile[MAXPATHLEN + 1];
|
||||||
FILE *efp;
|
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)
|
if (hist == NULL)
|
||||||
error("history not active");
|
error("history not active");
|
||||||
@ -377,6 +393,7 @@ histcmd(argc, argv)
|
|||||||
--active;
|
--active;
|
||||||
if (displayhist)
|
if (displayhist)
|
||||||
displayhist = 0;
|
displayhist = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC char *
|
STATIC char *
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,15 +35,9 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)init.h 8.1 (Berkeley) 5/31/93
|
* @(#)init.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __STDC__
|
void init __P((void));
|
||||||
void init(void);
|
void reset __P((void));
|
||||||
void reset(void);
|
void initshellproc __P((void));
|
||||||
void initshellproc(void);
|
|
||||||
#else
|
|
||||||
void init();
|
|
||||||
void reset();
|
|
||||||
void initshellproc();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,22 +38,24 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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.
|
* 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 "shell.h"
|
||||||
|
#include "redir.h"
|
||||||
#include "syntax.h"
|
#include "syntax.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "output.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 "error.h"
|
||||||
#include "alias.h"
|
#include "alias.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "extern.h"
|
|
||||||
#ifndef NO_HISTORY
|
|
||||||
#include "myhistedit.h"
|
#include "myhistedit.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
|
#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 init_editline = 0; /* editline library initialized? */
|
||||||
int whichprompt; /* 1 == PS1, 2 == PS2 */
|
int whichprompt; /* 1 == PS1, 2 == PS2 */
|
||||||
|
|
||||||
#ifndef NO_HISTORY
|
|
||||||
EditLine *el; /* cookie for editline package */
|
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
|
#ifdef mkinit
|
||||||
INCLUDE "input.h"
|
INCLUDE "input.h"
|
||||||
@ -198,9 +187,7 @@ preadbuffer() {
|
|||||||
register char *p, *q;
|
register char *p, *q;
|
||||||
register int i;
|
register int i;
|
||||||
register int something;
|
register int something;
|
||||||
#ifndef NO_HISTORY
|
|
||||||
extern EditLine *el;
|
extern EditLine *el;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (parsefile->strpush) {
|
if (parsefile->strpush) {
|
||||||
popstring();
|
popstring();
|
||||||
@ -213,7 +200,6 @@ preadbuffer() {
|
|||||||
flushout(&errout);
|
flushout(&errout);
|
||||||
retry:
|
retry:
|
||||||
p = parsenextc = parsefile->buf;
|
p = parsenextc = parsefile->buf;
|
||||||
#ifndef NO_HISTORY
|
|
||||||
if (parsefile->fd == 0 && el) {
|
if (parsefile->fd == 0 && el) {
|
||||||
const char *rl_cp;
|
const char *rl_cp;
|
||||||
int len;
|
int len;
|
||||||
@ -227,12 +213,8 @@ retry:
|
|||||||
i = len;
|
i = len;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
regular_read:
|
|
||||||
i = read(parsefile->fd, p, BUFSIZ - 1);
|
i = read(parsefile->fd, p, BUFSIZ - 1);
|
||||||
#ifndef NO_HISTORY
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
eof:
|
eof:
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
@ -282,14 +264,12 @@ eof:
|
|||||||
parsenleft = q - parsefile->buf - 1;
|
parsenleft = q - parsefile->buf - 1;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
#ifndef NO_HISTORY
|
|
||||||
if (parsefile->fd == 0 && hist && something) {
|
if (parsefile->fd == 0 && hist && something) {
|
||||||
INTOFF;
|
INTOFF;
|
||||||
history(hist, whichprompt == 1 ? H_ENTER : H_ADD,
|
history(hist, whichprompt == 1 ? H_ENTER : H_ADD,
|
||||||
parsefile->buf);
|
parsefile->buf);
|
||||||
INTON;
|
INTON;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (vflag) {
|
if (vflag) {
|
||||||
/*
|
/*
|
||||||
* This isn't right. Most shells coordinate it with
|
* This isn't right. Most shells coordinate it with
|
||||||
@ -398,8 +378,7 @@ setinputfile(fname, push)
|
|||||||
|
|
||||||
void
|
void
|
||||||
setinputfd(fd, push)
|
setinputfd(fd, push)
|
||||||
int fd;
|
int fd, push;
|
||||||
int push;
|
|
||||||
{
|
{
|
||||||
if (push) {
|
if (push) {
|
||||||
pushfile();
|
pushfile();
|
||||||
@ -423,7 +402,7 @@ void
|
|||||||
setinputstring(string, push)
|
setinputstring(string, push)
|
||||||
char *string;
|
char *string;
|
||||||
int push;
|
int push;
|
||||||
{
|
{
|
||||||
INTOFF;
|
INTOFF;
|
||||||
if (push)
|
if (push)
|
||||||
pushfile();
|
pushfile();
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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 */
|
/* 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 char *parsenextc; /* next character in input buffer */
|
||||||
extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */
|
extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */
|
||||||
|
|
||||||
|
char *pfgets __P((char *, int));
|
||||||
#ifdef __STDC__
|
int pgetc __P((void));
|
||||||
char *pfgets(char *, int);
|
int preadbuffer __P((void));
|
||||||
int pgetc(void);
|
void pungetc __P((void));
|
||||||
int preadbuffer(void);
|
void pushstring __P((char *, int, void *));
|
||||||
void pungetc(void);
|
void popstring __P((void));
|
||||||
void pushstring(char *, int, void *);
|
void setinputfile __P((char *, int));
|
||||||
void setinputfile(char *, int);
|
void setinputfd __P((int, int));
|
||||||
void setinputfd(int, int);
|
void setinputstring __P((char *, int));
|
||||||
void setinputstring(char *, int);
|
void popfile __P((void));
|
||||||
void popfile(void);
|
void popallfiles __P((void));
|
||||||
void popallfiles(void);
|
void closescript __P((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
|
|
||||||
|
|
||||||
#define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer())
|
#define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer())
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,17 +38,32 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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"
|
#include "shell.h"
|
||||||
#if JOBS
|
#if JOBS
|
||||||
#include "sgtty.h"
|
#include "sgtty.h"
|
||||||
#undef CEOF /* syntax.h redefines this */
|
#undef CEOF /* syntax.h redefines this */
|
||||||
#endif
|
#endif
|
||||||
|
#include "redir.h"
|
||||||
|
#include "show.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "nodes.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 "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "mystring.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 */
|
struct job *jobtab; /* array of jobs */
|
||||||
@ -83,22 +86,14 @@ int initialpgrp; /* pgrp of shell on invocation */
|
|||||||
short curjob; /* current job */
|
short curjob; /* current job */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void restartjob __P((struct job *));
|
||||||
STATIC void restartjob(struct job *);
|
STATIC void freejob __P((struct job *));
|
||||||
STATIC struct job *getjob(char *);
|
STATIC struct job *getjob __P((char *));
|
||||||
STATIC void freejob(struct job *);
|
STATIC int dowait __P((int, struct job *));
|
||||||
STATIC int procrunning(int);
|
STATIC int onsigchild __P((void));
|
||||||
STATIC int dowait(int, struct job *);
|
STATIC int waitproc __P((int, int *));
|
||||||
STATIC int waitproc(int, int *);
|
STATIC void cmdtxt __P((union node *));
|
||||||
#else
|
STATIC void cmdputs __P((char *));
|
||||||
STATIC void restartjob();
|
|
||||||
STATIC struct job *getjob();
|
|
||||||
STATIC void freejob();
|
|
||||||
STATIC int procrunning();
|
|
||||||
STATIC int dowait();
|
|
||||||
STATIC int waitproc();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -159,6 +154,7 @@ setjobctl(on)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef mkinit
|
#ifdef mkinit
|
||||||
|
INCLUDE <stdlib.h>
|
||||||
|
|
||||||
SHELLPROC {
|
SHELLPROC {
|
||||||
backgndpid = -1;
|
backgndpid = -1;
|
||||||
@ -465,6 +461,8 @@ currentjob:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
error("No such job: %s", name);
|
error("No such job: %s", name);
|
||||||
|
/*NOTREACHED*/
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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. */
|
/* 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 short backgndpid; /* pid of last background process */
|
||||||
extern int job_warning; /* user was warned about stopped jobs */
|
extern int job_warning; /* user was warned about stopped jobs */
|
||||||
|
|
||||||
|
void setjobctl __P((int));
|
||||||
#ifdef __STDC__
|
int fgcmd __P((int, char **));
|
||||||
void setjobctl(int);
|
int bgcmd __P((int, char **));
|
||||||
void showjobs(int);
|
int jobscmd __P((int, char **));
|
||||||
struct job *makejob(union node *, int);
|
void showjobs __P((int));
|
||||||
int forkshell(struct job *, union node *, int);
|
int waitcmd __P((int, char **));
|
||||||
int waitforjob(struct job *);
|
int jobidcmd __P((int, char **));
|
||||||
char *commandtext(union node *);
|
struct job *makejob __P((union node *, int));
|
||||||
#else
|
int forkshell __P((struct job *, union node *, int));
|
||||||
void setjobctl();
|
int waitforjob __P((struct job *));
|
||||||
void showjobs();
|
int stoppedjobs __P((void));
|
||||||
struct job *makejob();
|
char *commandtext __P((union node *));
|
||||||
int forkshell();
|
|
||||||
int waitforjob();
|
|
||||||
char *commandtext();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ! JOBS
|
#if ! JOBS
|
||||||
#define setjobctl(on) /* do nothing */
|
#define setjobctl(on) /* do nothing */
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
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
|
#endif
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,11 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)mail.h 8.1 (Berkeley) 5/31/93
|
* @(#)mail.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __STDC__
|
void chkmail __P((int));
|
||||||
void chkmail(int);
|
|
||||||
#else
|
|
||||||
void chkmail();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -44,9 +44,9 @@ static char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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 <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mail.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 "input.h"
|
||||||
#include "trap.h"
|
#include "trap.h"
|
||||||
#include "var.h"
|
#include "var.h"
|
||||||
|
#include "show.h"
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
#include "extern.h"
|
|
||||||
|
|
||||||
#define PROFILE 0
|
#define PROFILE 0
|
||||||
|
|
||||||
@ -86,14 +88,8 @@ short profile_buf[16384];
|
|||||||
extern int etext();
|
extern int etext();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void read_profile __P((char *));
|
||||||
STATIC void read_profile(char *);
|
STATIC char *find_dot_file __P((char *));
|
||||||
char *getenv(char *);
|
|
||||||
#else
|
|
||||||
STATIC void read_profile();
|
|
||||||
char *getenv();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main routine. We initialize things, parse the arguments, execute
|
* 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);
|
monitor(0);
|
||||||
#endif
|
#endif
|
||||||
exitshell(exitstatus);
|
exitshell(exitstatus);
|
||||||
|
/*NOTREACHED*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -290,8 +288,10 @@ readcmdfile(name)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static char *
|
STATIC char *
|
||||||
find_dot_file(basename) char *basename; {
|
find_dot_file(basename)
|
||||||
|
char *basename;
|
||||||
|
{
|
||||||
static char localname[FILENAME_MAX+1];
|
static char localname[FILENAME_MAX+1];
|
||||||
char *fullname;
|
char *fullname;
|
||||||
char *path = pathval();
|
char *path = pathval();
|
||||||
@ -333,10 +333,12 @@ exitcmd(argc, argv)
|
|||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
if (stoppedjobs())
|
if (stoppedjobs())
|
||||||
return;
|
return 0;
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
exitstatus = number(argv[1]);
|
exitstatus = number(argv[1]);
|
||||||
exitshell(exitstatus);
|
exitshell(exitstatus);
|
||||||
|
/*NOTREACHED*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,16 +35,13 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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 rootpid; /* pid of main shell */
|
||||||
extern int rootshell; /* true if we aren't a child of the main shell */
|
extern int rootshell; /* true if we aren't a child of the main shell */
|
||||||
|
|
||||||
#ifdef __STDC__
|
void readcmdfile __P((char *));
|
||||||
void readcmdfile(char *);
|
void cmdloop __P((int));
|
||||||
void cmdloop(int);
|
int dotcmd __P((int, char **));
|
||||||
#else
|
int exitcmd __P((int, char **));
|
||||||
void readcmdfile();
|
|
||||||
void cmdloop();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)memalloc.h 8.1 (Berkeley) 5/31/93
|
* @(#)memalloc.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct stackmark {
|
struct stackmark {
|
||||||
@ -50,35 +50,18 @@ extern int stacknleft;
|
|||||||
extern int sstrnleft;
|
extern int sstrnleft;
|
||||||
extern int herefd;
|
extern int herefd;
|
||||||
|
|
||||||
#ifdef __STDC__
|
pointer ckmalloc __P((int));
|
||||||
pointer ckmalloc(int);
|
pointer ckrealloc __P((pointer, int));
|
||||||
pointer ckrealloc(pointer, int);
|
char *savestr __P((char *));
|
||||||
void free(pointer); /* defined in C library */
|
pointer stalloc __P((int));
|
||||||
char *savestr(char *);
|
void stunalloc __P((pointer));
|
||||||
pointer stalloc(int);
|
void setstackmark __P((struct stackmark *));
|
||||||
void stunalloc(pointer);
|
void popstackmark __P((struct stackmark *));
|
||||||
void setstackmark(struct stackmark *);
|
void growstackblock __P((void));
|
||||||
void popstackmark(struct stackmark *);
|
void grabstackblock __P((int));
|
||||||
void growstackblock(void);
|
char *growstackstr __P((void));
|
||||||
void grabstackblock(int);
|
char *makestrspace __P((void));
|
||||||
char *growstackstr(void);
|
void ungrabstackstr __P((char *, char *));
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +69,7 @@ void ungrabstackstr();
|
|||||||
#define stackblocksize() stacknleft
|
#define stackblocksize() stacknleft
|
||||||
#define STARTSTACKSTR(p) p = stackblock(), sstrnleft = stackblocksize()
|
#define STARTSTACKSTR(p) p = stackblock(), sstrnleft = stackblocksize()
|
||||||
#define STPUTC(c, p) (--sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(), *p++ = (c)))
|
#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 USTPUTC(c, p) (--sstrnleft, *p++ = (c))
|
||||||
#define STACKSTRNUL(p) (sstrnleft == 0? (p = growstackstr(), *p = '\0') : (*p = '\0'))
|
#define STACKSTRNUL(p) (sstrnleft == 0? (p = growstackstr(), *p = '\0') : (*p = '\0'))
|
||||||
#define STUNPUTC(p) (++sstrnleft, --p)
|
#define STUNPUTC(p) (++sstrnleft, --p)
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "var.h"
|
#include "var.h"
|
||||||
@ -230,3 +233,161 @@ umaskcmd(argc, argv)
|
|||||||
}
|
}
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh -
|
#!/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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# @(#)mkbuiltins 8.1 (Berkeley) 5/31/93
|
# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95
|
||||||
|
|
||||||
temp=/tmp/ka$$
|
temp=/tmp/ka$$
|
||||||
havejobs=0
|
havejobs=0
|
||||||
@ -68,9 +68,9 @@ echo '};
|
|||||||
|
|
||||||
const struct builtincmd builtincmd[] = {'
|
const struct builtincmd builtincmd[] = {'
|
||||||
awk '{ for (i = 2 ; i <= NF ; i++) {
|
awk '{ for (i = 2 ; i <= NF ; i++) {
|
||||||
printf "\t\"%s\", %d,\n", $i, NR-1
|
printf "\t{ \"%s\", %d },\n", $i, NR-1
|
||||||
}}' $temp
|
}}' $temp
|
||||||
echo ' NULL, 0
|
echo ' { NULL, 0 }
|
||||||
};'
|
};'
|
||||||
|
|
||||||
exec > ${objdir}/builtins.h
|
exec > ${objdir}/builtins.h
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -44,9 +44,9 @@ static char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -156,16 +156,22 @@ struct text decls; /* declarations */
|
|||||||
int amiddecls; /* for formatting */
|
int amiddecls; /* for formatting */
|
||||||
|
|
||||||
|
|
||||||
void readfile(), doevent(), doinclude(), dodecl(), output();
|
void readfile __P((char *));
|
||||||
void addstr(), addchar(), writetext();
|
|
||||||
FILE *ckfopen();
|
|
||||||
void *ckmalloc __P((int));
|
|
||||||
void error();
|
|
||||||
int file_changed();
|
|
||||||
int match __P((char *, char *));
|
int match __P((char *, char *));
|
||||||
int gooddefine __P((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 *));
|
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)
|
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
||||||
|
|
||||||
|
138
bin/sh/mknodes.c
138
bin/sh/mknodes.c
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -44,9 +44,9 @@ static char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define MAXTYPES 50 /* max number of node types */
|
#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 */
|
static int ntypes; /* number of node types */
|
||||||
char *nodename[MAXTYPES]; /* names of the nodes */
|
static char *nodename[MAXTYPES]; /* names of the nodes */
|
||||||
struct str *nodestr[MAXTYPES]; /* type of structure used by the node */
|
static struct str *nodestr[MAXTYPES]; /* type of structure used by the node */
|
||||||
int nstr; /* number of structures */
|
static int nstr; /* number of structures */
|
||||||
struct str str[MAXTYPES]; /* the structures */
|
static struct str str[MAXTYPES]; /* the structures */
|
||||||
struct str *curstr; /* current structure */
|
static struct str *curstr; /* current structure */
|
||||||
FILE *infp = stdin;
|
static FILE *infp = stdin;
|
||||||
char line[1024];
|
static char line[1024];
|
||||||
int linno;
|
static int linno;
|
||||||
char *linep;
|
static char *linep;
|
||||||
|
|
||||||
void indent __P((int, FILE *));
|
static void parsenode __P((void));
|
||||||
int nextfield __P((char *));
|
static void parsefield __P((void));
|
||||||
void outfunc __P((FILE *, int));
|
static void output __P((char *));
|
||||||
void output __P((char *));
|
static void outsizes __P((FILE *));
|
||||||
void outsizes __P((FILE *));
|
static void outfunc __P((FILE *, int));
|
||||||
void parsefield();
|
static void indent __P((int, FILE *));
|
||||||
void parsenode();
|
static int nextfield __P((char *));
|
||||||
int readline();
|
static void skipbl __P((void));
|
||||||
char *savestr();
|
static int readline __P((void));
|
||||||
void skipbl();
|
static void error __P((const char *, ...));
|
||||||
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
static char *savestr __P((const char *));
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -133,8 +138,9 @@ main(argc, argv)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
parsenode() {
|
parsenode()
|
||||||
|
{
|
||||||
char name[BUFLEN];
|
char name[BUFLEN];
|
||||||
char tag[BUFLEN];
|
char tag[BUFLEN];
|
||||||
struct str *sp;
|
struct str *sp;
|
||||||
@ -148,7 +154,7 @@ parsenode() {
|
|||||||
error("Garbage at end of line");
|
error("Garbage at end of line");
|
||||||
nodename[ntypes] = savestr(name);
|
nodename[ntypes] = savestr(name);
|
||||||
for (sp = str ; sp < str + nstr ; sp++) {
|
for (sp = str ; sp < str + nstr ; sp++) {
|
||||||
if (equal(sp->tag, tag))
|
if (strcmp(sp->tag, tag) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sp >= str + nstr) {
|
if (sp >= str + nstr) {
|
||||||
@ -162,8 +168,9 @@ parsenode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
parsefield() {
|
parsefield()
|
||||||
|
{
|
||||||
char name[BUFLEN];
|
char name[BUFLEN];
|
||||||
char type[BUFLEN];
|
char type[BUFLEN];
|
||||||
char decl[2 * BUFLEN];
|
char decl[2 * BUFLEN];
|
||||||
@ -177,21 +184,21 @@ parsefield() {
|
|||||||
error("No field type");
|
error("No field type");
|
||||||
fp = &curstr->field[curstr->nfields];
|
fp = &curstr->field[curstr->nfields];
|
||||||
fp->name = savestr(name);
|
fp->name = savestr(name);
|
||||||
if (equal(type, "nodeptr")) {
|
if (strcmp(type, "nodeptr") == 0) {
|
||||||
fp->type = T_NODE;
|
fp->type = T_NODE;
|
||||||
sprintf(decl, "union node *%s", name);
|
sprintf(decl, "union node *%s", name);
|
||||||
} else if (equal(type, "nodelist")) {
|
} else if (strcmp(type, "nodelist") == 0) {
|
||||||
fp->type = T_NODELIST;
|
fp->type = T_NODELIST;
|
||||||
sprintf(decl, "struct nodelist *%s", name);
|
sprintf(decl, "struct nodelist *%s", name);
|
||||||
} else if (equal(type, "string")) {
|
} else if (strcmp(type, "string") == 0) {
|
||||||
fp->type = T_STRING;
|
fp->type = T_STRING;
|
||||||
sprintf(decl, "char *%s", name);
|
sprintf(decl, "char *%s", name);
|
||||||
} else if (equal(type, "int")) {
|
} else if (strcmp(type, "int") == 0) {
|
||||||
fp->type = T_INT;
|
fp->type = T_INT;
|
||||||
sprintf(decl, "int %s", name);
|
sprintf(decl, "int %s", name);
|
||||||
} else if (equal(type, "other")) {
|
} else if (strcmp(type, "other") == 0) {
|
||||||
fp->type = T_OTHER;
|
fp->type = T_OTHER;
|
||||||
} else if (equal(type, "temp")) {
|
} else if (strcmp(type, "temp") == 0) {
|
||||||
fp->type = T_TEMP;
|
fp->type = T_TEMP;
|
||||||
} else {
|
} else {
|
||||||
error("Unknown type %s", type);
|
error("Unknown type %s", type);
|
||||||
@ -214,7 +221,7 @@ char writer[] = "\
|
|||||||
*/\n\
|
*/\n\
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
void
|
static void
|
||||||
output(file)
|
output(file)
|
||||||
char *file;
|
char *file;
|
||||||
{
|
{
|
||||||
@ -264,11 +271,11 @@ output(file)
|
|||||||
fputs(writer, cfile);
|
fputs(writer, cfile);
|
||||||
while (fgets(line, sizeof line, patfile) != NULL) {
|
while (fgets(line, sizeof line, patfile) != NULL) {
|
||||||
for (p = line ; *p == ' ' || *p == '\t' ; p++);
|
for (p = line ; *p == ' ' || *p == '\t' ; p++);
|
||||||
if (equal(p, "%SIZES\n"))
|
if (strcmp(p, "%SIZES\n") == 0)
|
||||||
outsizes(cfile);
|
outsizes(cfile);
|
||||||
else if (equal(p, "%CALCSIZE\n"))
|
else if (strcmp(p, "%CALCSIZE\n") == 0)
|
||||||
outfunc(cfile, 1);
|
outfunc(cfile, 1);
|
||||||
else if (equal(p, "%COPY\n"))
|
else if (strcmp(p, "%COPY\n") == 0)
|
||||||
outfunc(cfile, 0);
|
outfunc(cfile, 0);
|
||||||
else
|
else
|
||||||
fputs(line, cfile);
|
fputs(line, cfile);
|
||||||
@ -277,7 +284,7 @@ output(file)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
outsizes(cfile)
|
outsizes(cfile)
|
||||||
FILE *cfile;
|
FILE *cfile;
|
||||||
{
|
{
|
||||||
@ -291,7 +298,7 @@ outsizes(cfile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
outfunc(cfile, calcsize)
|
outfunc(cfile, calcsize)
|
||||||
FILE *cfile;
|
FILE *cfile;
|
||||||
int calcsize;
|
int calcsize;
|
||||||
@ -372,7 +379,7 @@ outfunc(cfile, calcsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
indent(amount, fp)
|
indent(amount, fp)
|
||||||
int amount;
|
int amount;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -387,7 +394,7 @@ indent(amount, fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
nextfield(buf)
|
nextfield(buf)
|
||||||
char *buf;
|
char *buf;
|
||||||
{
|
{
|
||||||
@ -405,15 +412,17 @@ nextfield(buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
skipbl() {
|
skipbl()
|
||||||
|
{
|
||||||
while (*linep == ' ' || *linep == '\t')
|
while (*linep == ' ' || *linep == '\t')
|
||||||
linep++;
|
linep++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
readline() {
|
readline()
|
||||||
|
{
|
||||||
register char *p;
|
register char *p;
|
||||||
|
|
||||||
if (fgets(line, 1024, infp) == NULL)
|
if (fgets(line, 1024, infp) == NULL)
|
||||||
@ -431,25 +440,42 @@ readline() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
error(msg, a1, a2, a3, a4, a5, a6)
|
static void
|
||||||
char *msg;
|
#if __STDC__
|
||||||
|
error(const char *msg, ...)
|
||||||
|
#else
|
||||||
|
error(va_alist)
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(stderr, "line %d: ", linno);
|
va_list va;
|
||||||
fprintf(stderr, msg, a1, a2, a3, a4, a5, a6);
|
#if __STDC__
|
||||||
putc('\n', stderr);
|
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);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
savestr(s)
|
savestr(s)
|
||||||
char *s;
|
const char *s;
|
||||||
{
|
{
|
||||||
register char *p;
|
register char *p;
|
||||||
|
|
||||||
if ((p = malloc(strlen(s) + 1)) == NULL)
|
if ((p = malloc(strlen(s) + 1)) == NULL)
|
||||||
error("Out of space");
|
error("Out of space");
|
||||||
strcpy(p, s);
|
(void) strcpy(p, s);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -44,9 +44,9 @@ static char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -66,21 +66,21 @@ struct synclass {
|
|||||||
|
|
||||||
/* Syntax classes */
|
/* Syntax classes */
|
||||||
struct synclass synclass[] = {
|
struct synclass synclass[] = {
|
||||||
"CWORD", "character is nothing special",
|
{ "CWORD", "character is nothing special" },
|
||||||
"CNL", "newline character",
|
{ "CNL", "newline character" },
|
||||||
"CBACK", "a backslash character",
|
{ "CBACK", "a backslash character" },
|
||||||
"CSQUOTE", "single quote",
|
{ "CSQUOTE", "single quote" },
|
||||||
"CDQUOTE", "double quote",
|
{ "CDQUOTE", "double quote" },
|
||||||
"CENDQUOTE", "a terminating quote",
|
{ "CENDQUOTE", "a terminating quote" },
|
||||||
"CBQUOTE", "backwards single quote",
|
{ "CBQUOTE", "backwards single quote" },
|
||||||
"CVAR", "a dollar sign",
|
{ "CVAR", "a dollar sign" },
|
||||||
"CENDVAR", "a '}' character",
|
{ "CENDVAR", "a '}' character" },
|
||||||
"CLP", "a left paren in arithmetic",
|
{ "CLP", "a left paren in arithmetic" },
|
||||||
"CRP", "a right paren in arithmetic",
|
{ "CRP", "a right paren in arithmetic" },
|
||||||
"CEOF", "end of file",
|
{ "CEOF", "end of file" },
|
||||||
"CCTL", "like CWORD, except it must be escaped",
|
{ "CCTL", "like CWORD, except it must be escaped" },
|
||||||
"CSPCL", "these terminate a word",
|
{ "CSPCL", "these terminate a word" },
|
||||||
NULL, NULL
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -89,40 +89,40 @@ struct synclass synclass[] = {
|
|||||||
* you may have to change the definition of the is_in_name macro.
|
* you may have to change the definition of the is_in_name macro.
|
||||||
*/
|
*/
|
||||||
struct synclass is_entry[] = {
|
struct synclass is_entry[] = {
|
||||||
"ISDIGIT", "a digit",
|
{ "ISDIGIT", "a digit" },
|
||||||
"ISUPPER", "an upper case letter",
|
{ "ISUPPER", "an upper case letter" },
|
||||||
"ISLOWER", "a lower case letter",
|
{ "ISLOWER", "a lower case letter" },
|
||||||
"ISUNDER", "an underscore",
|
{ "ISUNDER", "an underscore" },
|
||||||
"ISSPECL", "the name of a special parameter",
|
{ "ISSPECL", "the name of a special parameter" },
|
||||||
NULL, NULL,
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
char writer[] = "\
|
static char writer[] = "\
|
||||||
/*\n\
|
/*\n\
|
||||||
* This file was generated by the mksyntax program.\n\
|
* This file was generated by the mksyntax program.\n\
|
||||||
*/\n\
|
*/\n\
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
|
|
||||||
FILE *cfile;
|
static FILE *cfile;
|
||||||
FILE *hfile;
|
static FILE *hfile;
|
||||||
char *syntax[513];
|
static char *syntax[513];
|
||||||
int base;
|
static int base;
|
||||||
int size; /* number of values which a char variable can have */
|
static int size; /* number of values which a char variable can have */
|
||||||
int nbits; /* number of bits in a character */
|
static int nbits; /* number of bits in a character */
|
||||||
int digit_contig; /* true if digits are contiguous */
|
static int digit_contig;/* true if digits are contiguous */
|
||||||
|
|
||||||
void add __P((char *, char *));
|
static void filltable __P((char *));
|
||||||
void digit_convert();
|
static void init __P((void));
|
||||||
void filltable __P((char *));
|
static void add __P((char *, char *));
|
||||||
void init();
|
static void print __P((char *));
|
||||||
void output_type_macros();
|
static void output_type_macros __P((void));
|
||||||
void print __P((char *));
|
static void digit_convert __P((void));
|
||||||
|
|
||||||
int
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char **argv;
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
char d;
|
char d;
|
||||||
@ -177,7 +177,7 @@ main(argc, argv)
|
|||||||
for (i = 0 ; synclass[i].name ; i++) {
|
for (i = 0 ; synclass[i].name ; i++) {
|
||||||
sprintf(buf, "#define %s %d", synclass[i].name, i);
|
sprintf(buf, "#define %s %d", synclass[i].name, i);
|
||||||
fputs(buf, hfile);
|
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);
|
putc('\t', hfile);
|
||||||
fprintf(hfile, "/* %s */\n", synclass[i].comment);
|
fprintf(hfile, "/* %s */\n", synclass[i].comment);
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ main(argc, argv)
|
|||||||
for (i = 0 ; is_entry[i].name ; i++) {
|
for (i = 0 ; is_entry[i].name ; i++) {
|
||||||
sprintf(buf, "#define %s %#o", is_entry[i].name, 1 << i);
|
sprintf(buf, "#define %s %#o", is_entry[i].name, 1 << i);
|
||||||
fputs(buf, hfile);
|
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);
|
putc('\t', hfile);
|
||||||
fprintf(hfile, "/* %s */\n", is_entry[i].comment);
|
fprintf(hfile, "/* %s */\n", is_entry[i].comment);
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ main(argc, argv)
|
|||||||
* Clear the syntax table.
|
* Clear the syntax table.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
filltable(dftval)
|
filltable(dftval)
|
||||||
char *dftval;
|
char *dftval;
|
||||||
{
|
{
|
||||||
@ -280,8 +280,9 @@ filltable(dftval)
|
|||||||
* Initialize the syntax table with default values.
|
* Initialize the syntax table with default values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
init() {
|
init()
|
||||||
|
{
|
||||||
filltable("CWORD");
|
filltable("CWORD");
|
||||||
syntax[0] = "CEOF";
|
syntax[0] = "CEOF";
|
||||||
syntax[base + CTLESC] = "CCTL";
|
syntax[base + CTLESC] = "CCTL";
|
||||||
@ -298,7 +299,7 @@ init() {
|
|||||||
* Add entries to the syntax table.
|
* Add entries to the syntax table.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
add(p, type)
|
add(p, type)
|
||||||
char *p, *type;
|
char *p, *type;
|
||||||
{
|
{
|
||||||
@ -312,7 +313,7 @@ add(p, type)
|
|||||||
* Output the syntax table.
|
* Output the syntax table.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
print(name)
|
print(name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
@ -346,7 +347,7 @@ print(name)
|
|||||||
* contiguous, we can test for them quickly.
|
* contiguous, we can test for them quickly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *macro[] = {
|
static char *macro[] = {
|
||||||
"#define is_digit(c)\t((is_type+SYNBASE)[c] & ISDIGIT)",
|
"#define is_digit(c)\t((is_type+SYNBASE)[c] & ISDIGIT)",
|
||||||
"#define is_alpha(c)\t((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER))",
|
"#define is_alpha(c)\t((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER))",
|
||||||
"#define is_name(c)\t((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER|ISUNDER))",
|
"#define is_name(c)\t((is_type+SYNBASE)[c] & (ISUPPER|ISLOWER|ISUNDER))",
|
||||||
@ -355,7 +356,7 @@ char *macro[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
static void
|
||||||
output_type_macros()
|
output_type_macros()
|
||||||
{
|
{
|
||||||
char **pp;
|
char **pp;
|
||||||
@ -376,7 +377,7 @@ output_type_macros()
|
|||||||
* Output digit conversion table (if digits are not contiguous).
|
* Output digit conversion table (if digits are not contiguous).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
static void
|
||||||
digit_convert()
|
digit_convert()
|
||||||
{
|
{
|
||||||
int maxdigit;
|
int maxdigit;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh -
|
#!/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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# The Regents of the University of California. All rights reserved.
|
||||||
|
@ -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
|
* Copyright (c) 1993
|
||||||
@ -32,7 +32,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)myhistedit.h 8.1 (Berkeley) 5/31/93
|
* @(#)myhistedit.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <histedit.h>
|
#include <histedit.h>
|
||||||
@ -40,3 +40,10 @@
|
|||||||
extern History *hist;
|
extern History *hist;
|
||||||
extern EditLine *el;
|
extern EditLine *el;
|
||||||
extern int displayhist;
|
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));
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,22 +35,15 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)mystring.h 8.1 (Berkeley) 5/31/93
|
* @(#)mystring.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __STDC__
|
void scopyn __P((const char *, char *, int));
|
||||||
void scopyn(const char *, char *, int);
|
int prefix __P((const char *, const char *));
|
||||||
int prefix(const char *, const char *);
|
int number __P((const char *));
|
||||||
int number(const char *);
|
int is_number __P((const char *));
|
||||||
int is_number(const char *);
|
|
||||||
#else
|
|
||||||
void scopyn();
|
|
||||||
int prefix();
|
|
||||||
int number();
|
|
||||||
int is_number();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
||||||
#define scopy(s1, s2) ((void)strcpy(s2, s1))
|
#define scopy(s1, s2) ((void)strcpy(s2, s1))
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,9 +35,10 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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.
|
* Routine for dealing with parsed shell commands.
|
||||||
*/
|
*/
|
||||||
@ -49,31 +50,19 @@
|
|||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
|
|
||||||
|
|
||||||
int funcblocksize; /* size of structures in function */
|
int funcblocksize; /* size of structures in function */
|
||||||
int funcstringsize; /* size of strings in node */
|
int funcstringsize; /* size of strings in node */
|
||||||
#ifdef __STDC__
|
|
||||||
pointer funcblock; /* block to allocate function from */
|
pointer funcblock; /* block to allocate function from */
|
||||||
#else
|
char *funcstring; /* block to allocate strings from */
|
||||||
char *funcblock; /* block to allocate function from */
|
|
||||||
#endif
|
|
||||||
char *funcstring; /* block to allocate strings from */
|
|
||||||
|
|
||||||
%SIZES
|
%SIZES
|
||||||
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void calcsize __P((union node *));
|
||||||
STATIC void calcsize(union node *);
|
STATIC void sizenodelist __P((struct nodelist *));
|
||||||
STATIC void sizenodelist(struct nodelist *);
|
STATIC union node *copynode __P((union node *));
|
||||||
STATIC union node *copynode(union node *);
|
STATIC struct nodelist *copynodelist __P((struct nodelist *));
|
||||||
STATIC struct nodelist *copynodelist(struct nodelist *);
|
STATIC char *nodesavestr __P((char *));
|
||||||
STATIC char *nodesavestr(char *);
|
|
||||||
#else
|
|
||||||
STATIC void calcsize();
|
|
||||||
STATIC void sizenodelist();
|
|
||||||
STATIC union node *copynode();
|
|
||||||
STATIC struct nodelist *copynodelist();
|
|
||||||
STATIC char *nodesavestr();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -83,85 +72,86 @@ STATIC char *nodesavestr();
|
|||||||
|
|
||||||
union node *
|
union node *
|
||||||
copyfunc(n)
|
copyfunc(n)
|
||||||
union node *n;
|
union node *n;
|
||||||
{
|
{
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
funcblocksize = 0;
|
funcblocksize = 0;
|
||||||
funcstringsize = 0;
|
funcstringsize = 0;
|
||||||
calcsize(n);
|
calcsize(n);
|
||||||
funcblock = ckmalloc(funcblocksize + funcstringsize);
|
funcblock = ckmalloc(funcblocksize + funcstringsize);
|
||||||
funcstring = funcblock + funcblocksize;
|
funcstring = funcblock + funcblocksize;
|
||||||
return copynode(n);
|
return copynode(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
calcsize(n)
|
calcsize(n)
|
||||||
union node *n;
|
union node *n;
|
||||||
{
|
{
|
||||||
%CALCSIZE
|
%CALCSIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
sizenodelist(lp)
|
sizenodelist(lp)
|
||||||
struct nodelist *lp;
|
struct nodelist *lp;
|
||||||
{
|
{
|
||||||
while (lp) {
|
while (lp) {
|
||||||
funcblocksize += ALIGN(sizeof (struct nodelist));
|
funcblocksize += ALIGN(sizeof(struct nodelist));
|
||||||
calcsize(lp->n);
|
calcsize(lp->n);
|
||||||
lp = lp->next;
|
lp = lp->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STATIC union node *
|
STATIC union node *
|
||||||
copynode(n)
|
copynode(n)
|
||||||
union node *n;
|
union node *n;
|
||||||
{
|
{
|
||||||
union node *new;
|
union node *new;
|
||||||
|
|
||||||
%COPY
|
%COPY
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STATIC struct nodelist *
|
STATIC struct nodelist *
|
||||||
copynodelist(lp)
|
copynodelist(lp)
|
||||||
struct nodelist *lp;
|
struct nodelist *lp;
|
||||||
{
|
{
|
||||||
struct nodelist *start;
|
struct nodelist *start;
|
||||||
struct nodelist **lpp;
|
struct nodelist **lpp;
|
||||||
|
|
||||||
lpp = &start;
|
lpp = &start;
|
||||||
while (lp) {
|
while (lp) {
|
||||||
*lpp = funcblock;
|
*lpp = funcblock;
|
||||||
funcblock += ALIGN(sizeof (struct nodelist));
|
funcblock += ALIGN(sizeof(struct nodelist));
|
||||||
(*lpp)->n = copynode(lp->n);
|
(*lpp)->n = copynode(lp->n);
|
||||||
lp = lp->next;
|
lp = lp->next;
|
||||||
lpp = &(*lpp)->next;
|
lpp = &(*lpp)->next;
|
||||||
}
|
}
|
||||||
*lpp = NULL;
|
*lpp = NULL;
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STATIC char *
|
STATIC char *
|
||||||
nodesavestr(s)
|
nodesavestr(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register char *p = s;
|
register char *p = s;
|
||||||
register char *q = funcstring;
|
register char *q = funcstring;
|
||||||
char *rtn = funcstring;
|
char *rtn = funcstring;
|
||||||
|
|
||||||
while (*q++ = *p++);
|
while ((*q++ = *p++) != '\0')
|
||||||
funcstring = q;
|
continue;
|
||||||
return rtn;
|
funcstring = q;
|
||||||
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,8 +162,8 @@ nodesavestr(s)
|
|||||||
|
|
||||||
void
|
void
|
||||||
freefunc(n)
|
freefunc(n)
|
||||||
union node *n;
|
union node *n;
|
||||||
{
|
{
|
||||||
if (n)
|
if (n)
|
||||||
ckfree(n);
|
ckfree(n);
|
||||||
}
|
}
|
||||||
|
@ -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
|
# Copyright (c) 1991, 1993
|
||||||
# The Regents of the University of California. All rights reserved.
|
# 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
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# 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
|
# This file describes the nodes used in parse trees. Unindented lines
|
||||||
# contain a node type followed by a structure tag. Subsequent indented
|
# 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
|
dupfd int # file descriptor to duplicate
|
||||||
vname nodeptr # file name if fd>&$var
|
vname nodeptr # file name if fd>&$var
|
||||||
|
|
||||||
|
|
||||||
NHERE nhere # fd<<\!
|
NHERE nhere # fd<<\!
|
||||||
NXHERE nhere # fd<<!
|
NXHERE nhere # fd<<!
|
||||||
type int
|
type int
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,12 +38,16 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#define DEFINE_OPTIONS
|
#define DEFINE_OPTIONS
|
||||||
#include "options.h"
|
#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 "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "extern.h"
|
#ifndef NO_HISTORY
|
||||||
#include <unistd.h>
|
#include "myhistedit.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
char *arg0; /* value of $0 */
|
char *arg0; /* value of $0 */
|
||||||
struct shparam shellparam; /* current positional parameters */
|
struct shparam shellparam; /* current positional parameters */
|
||||||
@ -70,16 +75,9 @@ char *optptr; /* used by nextopt */
|
|||||||
char *minusc; /* argument to -c option */
|
char *minusc; /* argument to -c option */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void options __P((int));
|
||||||
STATIC void options(int);
|
STATIC void minus_o __P((char *, int));
|
||||||
STATIC void setoption(int, int);
|
STATIC void setoption __P((int, int));
|
||||||
STATIC void minus_o(char *, int);
|
|
||||||
#else
|
|
||||||
STATIC void options();
|
|
||||||
STATIC void setoption();
|
|
||||||
STATIC void minus_o();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -152,7 +150,7 @@ options(cmdline)
|
|||||||
argptr++;
|
argptr++;
|
||||||
if ((c = *p++) == '-') {
|
if ((c = *p++) == '-') {
|
||||||
val = 1;
|
val = 1;
|
||||||
if (p[0] == '\0' || p[0] == '-' && p[1] == '\0') {
|
if (p[0] == '\0' || (p[0] == '-' && p[1] == '\0')) {
|
||||||
if (!cmdline) {
|
if (!cmdline) {
|
||||||
/* "-" means turn off -x and -v */
|
/* "-" means turn off -x and -v */
|
||||||
if (p[0] == '\0')
|
if (p[0] == '\0')
|
||||||
@ -242,7 +240,6 @@ setoption(flag, val)
|
|||||||
|
|
||||||
#ifdef mkinit
|
#ifdef mkinit
|
||||||
INCLUDE "options.h"
|
INCLUDE "options.h"
|
||||||
INCLUDE "extern.h"
|
|
||||||
|
|
||||||
SHELLPROC {
|
SHELLPROC {
|
||||||
int i;
|
int i;
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)options.h 8.1 (Berkeley) 5/31/93
|
* @(#)options.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct shparam {
|
struct shparam {
|
||||||
@ -74,21 +74,21 @@ struct optent {
|
|||||||
|
|
||||||
#ifdef DEFINE_OPTIONS
|
#ifdef DEFINE_OPTIONS
|
||||||
struct optent optlist[NOPTS] = {
|
struct optent optlist[NOPTS] = {
|
||||||
"errexit", 'e', 0,
|
{ "errexit", 'e', 0 },
|
||||||
"noglob", 'f', 0,
|
{ "noglob", 'f', 0 },
|
||||||
"ignoreeof", 'I', 0,
|
{ "ignoreeof", 'I', 0 },
|
||||||
"interactive", 'i', 0,
|
{ "interactive",'i', 0 },
|
||||||
"monitor", 'm', 0,
|
{ "monitor", 'm', 0 },
|
||||||
"noexec", 'n', 0,
|
{ "noexec", 'n', 0 },
|
||||||
"stdin", 's', 0,
|
{ "stdin", 's', 0 },
|
||||||
"xtrace", 'x', 0,
|
{ "xtrace", 'x', 0 },
|
||||||
"verbose", 'v', 0,
|
{ "verbose", 'v', 0 },
|
||||||
"vi", 'V', 0,
|
{ "vi", 'V', 0 },
|
||||||
"emacs", 'E', 0,
|
{ "emacs", 'E', 0 },
|
||||||
"noclobber", 'C', 0,
|
{ "noclobber", 'C', 0 },
|
||||||
"allexport", 'a', 0,
|
{ "allexport", 'a', 0 },
|
||||||
"notify", 'b', 0,
|
{ "notify", 'b', 0 },
|
||||||
"nounset", 'u', 0,
|
{ "nounset", 'u', 0 },
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
extern struct optent optlist[NOPTS];
|
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 *optarg; /* set by nextopt */
|
||||||
extern char *optptr; /* used by nextopt */
|
extern char *optptr; /* used by nextopt */
|
||||||
|
|
||||||
|
void procargs __P((int, char **));
|
||||||
#ifdef __STDC__
|
void optschanged __P((void));
|
||||||
void procargs(int, char **);
|
void setparam __P((char **));
|
||||||
void setparam(char **);
|
void freeparam __P((struct shparam *));
|
||||||
void freeparam(struct shparam *);
|
int shiftcmd __P((int, char **));
|
||||||
int nextopt(char *);
|
int setcmd __P((int, char **));
|
||||||
#else
|
int getoptscmd __P((int, char **));
|
||||||
void procargs();
|
int nextopt __P((char *));
|
||||||
void setparam();
|
|
||||||
void freeparam();
|
|
||||||
int nextopt();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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 <stdio.h> /* defines BUFSIZ */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "shell.h"
|
|
||||||
#include "syntax.h"
|
|
||||||
#include "output.h"
|
|
||||||
#include "memalloc.h"
|
|
||||||
#include "error.h"
|
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
#include "stdarg.h"
|
#include <stdarg.h>
|
||||||
#else
|
#else
|
||||||
#include <varargs.h>
|
#include <varargs.h>
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.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
|
#define OUTBUFSIZ BUFSIZ
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,11 +35,17 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)output.h 8.1 (Berkeley) 5/31/93
|
* @(#)output.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OUTPUT_INCL
|
#ifndef OUTPUT_INCL
|
||||||
|
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct output {
|
struct output {
|
||||||
char *nextc;
|
char *nextc;
|
||||||
int nleft;
|
int nleft;
|
||||||
@ -55,38 +61,21 @@ extern struct output memout;
|
|||||||
extern struct output *out1;
|
extern struct output *out1;
|
||||||
extern struct output *out2;
|
extern struct output *out2;
|
||||||
|
|
||||||
|
void open_mem __P((char *, int, struct output *));
|
||||||
#ifdef __STDC__
|
void out1str __P((const char *));
|
||||||
void outstr(const char *, struct output *);
|
void out2str __P((const char *));
|
||||||
void out1str(const char *);
|
void outstr __P((const char *, struct output *));
|
||||||
void out2str(const char *);
|
void emptyoutbuf __P((struct output *));
|
||||||
void outfmt(struct output *, char *, ...);
|
void flushall __P((void));
|
||||||
void out1fmt(char *, ...);
|
void flushout __P((struct output *));
|
||||||
void fmtstr(char *, int, char *, ...);
|
void freestdout __P((void));
|
||||||
/* void doformat(struct output *, char *, va_list); */
|
void outfmt __P((struct output *, char *, ...));
|
||||||
void doformat();
|
void out1fmt __P((char *, ...));
|
||||||
void emptyoutbuf(struct output *);
|
void dprintf __P((char *, ...));
|
||||||
void flushall(void);
|
void fmtstr __P((char *, int, char *, ...));
|
||||||
void flushout(struct output *);
|
void doformat __P((struct output *, char *, va_list));
|
||||||
void freestdout(void);
|
int xwrite __P((int, char *, int));
|
||||||
int xwrite(int, char *, int);
|
int xioctl __P((int, unsigned long, char *));
|
||||||
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
|
|
||||||
|
|
||||||
#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
|
#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
|
||||||
#define out1c(c) outc(c, out1);
|
#define out1c(c) outc(c, out1);
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,12 +38,14 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "nodes.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 "memalloc.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "alias.h"
|
#include "alias.h"
|
||||||
|
#include "show.h"
|
||||||
#ifndef NO_HISTORY
|
#ifndef NO_HISTORY
|
||||||
#include "myhistedit.h"
|
#include "myhistedit.h"
|
||||||
#endif
|
#endif
|
||||||
@ -112,11 +115,11 @@ STATIC union node *simplecmd __P((union node **, union node *));
|
|||||||
STATIC union node *makename __P((void));
|
STATIC union node *makename __P((void));
|
||||||
STATIC void parsefname __P((void));
|
STATIC void parsefname __P((void));
|
||||||
STATIC void parseheredoc __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 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 synexpect __P((int));
|
||||||
STATIC void synerror __P((char *));
|
STATIC void synerror __P((char *));
|
||||||
STATIC void setprompt __P((int));
|
STATIC void setprompt __P((int));
|
||||||
@ -296,7 +299,8 @@ command() {
|
|||||||
int t;
|
int t;
|
||||||
|
|
||||||
checkkwd = 2;
|
checkkwd = 2;
|
||||||
redir = 0;
|
redir = NULL;
|
||||||
|
n1 = NULL;
|
||||||
rpp = &redir;
|
rpp = &redir;
|
||||||
/* Check for redirection which may precede command */
|
/* Check for redirection which may precede command */
|
||||||
while (readtoken() == TREDIR) {
|
while (readtoken() == TREDIR) {
|
||||||
@ -710,7 +714,7 @@ readtoken() {
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ap = lookupalias(wordtext, 1)) {
|
if ((ap = lookupalias(wordtext, 1)) != NULL) {
|
||||||
pushstring(ap->val, strlen(ap->val), ap);
|
pushstring(ap->val, strlen(ap->val), ap);
|
||||||
checkkwd = savecheckkwd;
|
checkkwd = savecheckkwd;
|
||||||
goto top;
|
goto top;
|
||||||
@ -846,8 +850,8 @@ readtoken1(firstc, syntax, eofmark, striptabs)
|
|||||||
char *eofmark;
|
char *eofmark;
|
||||||
int striptabs;
|
int striptabs;
|
||||||
{
|
{
|
||||||
register c = firstc;
|
int c = firstc;
|
||||||
register char *out;
|
char *out;
|
||||||
int len;
|
int len;
|
||||||
char line[EOFMARKLEN + 1];
|
char line[EOFMARKLEN + 1];
|
||||||
struct nodelist *bqlist;
|
struct nodelist *bqlist;
|
||||||
@ -858,6 +862,18 @@ readtoken1(firstc, syntax, eofmark, striptabs)
|
|||||||
int parenlevel; /* levels of parens in arithmetic */
|
int parenlevel; /* levels of parens in arithmetic */
|
||||||
int oldstyle;
|
int oldstyle;
|
||||||
char const *prevsyntax; /* syntax before arithmetic */
|
char const *prevsyntax; /* syntax before arithmetic */
|
||||||
|
#if __GNUC__
|
||||||
|
/* Avoid longjmp clobbering */
|
||||||
|
(void) &out;
|
||||||
|
(void) "ef;
|
||||||
|
(void) &dblquote;
|
||||||
|
(void) &varnest;
|
||||||
|
(void) &arinest;
|
||||||
|
(void) &parenlevel;
|
||||||
|
(void) &oldstyle;
|
||||||
|
(void) &prevsyntax;
|
||||||
|
(void) &syntax;
|
||||||
|
#endif
|
||||||
|
|
||||||
startlinno = plinno;
|
startlinno = plinno;
|
||||||
dblquote = 0;
|
dblquote = 0;
|
||||||
@ -1258,8 +1274,8 @@ parsebackq: {
|
|||||||
if (savelen > 0) {
|
if (savelen > 0) {
|
||||||
str = ckmalloc(savelen);
|
str = ckmalloc(savelen);
|
||||||
memcpy(str, stackblock(), savelen);
|
memcpy(str, stackblock(), savelen);
|
||||||
|
setinputstring(str, 1);
|
||||||
}
|
}
|
||||||
setinputstring(str, 1);
|
|
||||||
}
|
}
|
||||||
nlpp = &bqlist;
|
nlpp = &bqlist;
|
||||||
while (*nlpp)
|
while (*nlpp)
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)parser.h 8.1 (Berkeley) 5/31/93
|
* @(#)parser.h 8.3 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* control characters in argument strings */
|
/* control characters in argument strings */
|
||||||
@ -76,14 +76,7 @@ extern int tokpushback;
|
|||||||
extern int whichprompt; /* 1 == PS1, 2 == PS2 */
|
extern int whichprompt; /* 1 == PS1, 2 == PS2 */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __STDC__
|
union node *parsecmd __P((int));
|
||||||
union node *parsecmd(int);
|
void fixredir __P((union node *, const char *, int));
|
||||||
int goodname(char *);
|
int goodname __P((char *));
|
||||||
char *getprompt(void *);
|
char *getprompt __P((void *));
|
||||||
void fixredir(union node *, const char *, int);
|
|
||||||
#else
|
|
||||||
union node *parsecmd();
|
|
||||||
int goodname();
|
|
||||||
char *getprompt();
|
|
||||||
void fixredir();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,12 +38,20 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#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.
|
* 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 "output.h"
|
||||||
#include "memalloc.h"
|
#include "memalloc.h"
|
||||||
#include "error.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 */
|
#define EMPTY -2 /* marks an unused slot in redirtab */
|
||||||
@ -84,14 +86,8 @@ MKINIT struct redirtab *redirlist;
|
|||||||
*/
|
*/
|
||||||
int fd0_redirected = 0;
|
int fd0_redirected = 0;
|
||||||
|
|
||||||
#ifdef __STDC__
|
STATIC void openredirect __P((union node *, char[10 ]));
|
||||||
STATIC void openredirect(union node *, char *);
|
STATIC int openhere __P((union node *));
|
||||||
STATIC int openhere(union node *);
|
|
||||||
#else
|
|
||||||
STATIC void openredirect();
|
|
||||||
STATIC int openhere();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -228,7 +224,7 @@ openhere(redir)
|
|||||||
union node *redir;
|
union node *redir;
|
||||||
{
|
{
|
||||||
int pip[2];
|
int pip[2];
|
||||||
int len;
|
int len = 0;
|
||||||
|
|
||||||
if (pipe(pip) < 0)
|
if (pipe(pip) < 0)
|
||||||
error("Pipe call failed");
|
error("Pipe call failed");
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,24 +35,17 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)redir.h 8.1 (Berkeley) 5/31/93
|
* @(#)redir.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* flags passed to redirect */
|
/* flags passed to redirect */
|
||||||
#define REDIR_PUSH 01 /* save previous values of file descriptors */
|
#define REDIR_PUSH 01 /* save previous values of file descriptors */
|
||||||
#define REDIR_BACKQ 02 /* save the command output in memory */
|
#define REDIR_BACKQ 02 /* save the command output in memory */
|
||||||
|
|
||||||
#ifdef __STDC__
|
|
||||||
union node;
|
union node;
|
||||||
void redirect(union node *, int);
|
void redirect __P((union node *, int));
|
||||||
void popredir(void);
|
void popredir __P((void));
|
||||||
void clearredir(void);
|
int fd0_redirected_p __P((void));
|
||||||
int copyfd(int, int);
|
void clearredir __P((void));
|
||||||
int fd0_redirected_p(void);
|
int copyfd __P((int, int));
|
||||||
#else
|
|
||||||
void redirect();
|
|
||||||
void popredir();
|
|
||||||
void clearredir();
|
|
||||||
int copyfd();
|
|
||||||
int fd0_redirected_p();
|
|
||||||
#endif
|
|
||||||
|
@ -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
|
.\" Copyright (c) 1991, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" 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
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" @(#)sh.1 8.4 (Berkeley) 4/18/94
|
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
|
||||||
.\"
|
.\"
|
||||||
.na
|
.na
|
||||||
.TH SH 1
|
.TH SH 1
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)shell.h 8.1 (Berkeley) 5/31/93
|
* @(#)shell.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,26 +38,35 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#if __STDC__
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
|
#include <varargs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "extern.h"
|
#include "show.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#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 *));
|
static void trstring __P((char *));
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
showtree(n)
|
showtree(n)
|
||||||
union node *n;
|
union node *n;
|
||||||
{
|
{
|
||||||
@ -125,7 +134,7 @@ static void
|
|||||||
shcmd(cmd, fp)
|
shcmd(cmd, fp)
|
||||||
union node *cmd;
|
union node *cmd;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
{
|
{
|
||||||
union node *np;
|
union node *np;
|
||||||
int first;
|
int first;
|
||||||
char *s;
|
char *s;
|
||||||
@ -147,6 +156,7 @@ shcmd(cmd, fp)
|
|||||||
case NTOFD: s = ">&"; dftfd = 1; break;
|
case NTOFD: s = ">&"; dftfd = 1; break;
|
||||||
case NFROM: s = "<"; dftfd = 0; break;
|
case NFROM: s = "<"; dftfd = 0; break;
|
||||||
case NFROMFD: s = "<&"; dftfd = 0; break;
|
case NFROMFD: s = "<&"; dftfd = 0; break;
|
||||||
|
default: s = "*error*"; dftfd = 0; break;
|
||||||
}
|
}
|
||||||
if (np->nfile.fd != dftfd)
|
if (np->nfile.fd != dftfd)
|
||||||
fprintf(fp, "%d", np->nfile.fd);
|
fprintf(fp, "%d", np->nfile.fd);
|
||||||
@ -294,16 +304,29 @@ trputc(c)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
trace(fmt, a1, a2, a3, a4, a5, a6, a7, a8)
|
#if __STDC__
|
||||||
char *fmt;
|
trace(const char *fmt, ...)
|
||||||
{
|
#else
|
||||||
|
trace(va_alist)
|
||||||
|
va_dcl
|
||||||
|
#endif
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (tracefile == NULL)
|
va_list va;
|
||||||
return;
|
#if __STDC__
|
||||||
fprintf(tracefile, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
|
va_start(va, fmt);
|
||||||
if (strchr(fmt, '\n'))
|
#else
|
||||||
fflush(tracefile);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,22 +410,26 @@ trargs(ap)
|
|||||||
void
|
void
|
||||||
opentrace() {
|
opentrace() {
|
||||||
char s[100];
|
char s[100];
|
||||||
char *p;
|
|
||||||
char *getenv();
|
char *getenv();
|
||||||
|
#ifdef O_APPEND
|
||||||
int flags;
|
int flags;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!debug)
|
if (!debug)
|
||||||
return;
|
return;
|
||||||
#ifdef not_this_way
|
#ifdef not_this_way
|
||||||
if ((p = getenv("HOME")) == NULL) {
|
{
|
||||||
if (geteuid() == 0)
|
char *p;
|
||||||
p = "/";
|
if ((p = getenv("HOME")) == NULL) {
|
||||||
else
|
if (geteuid() == 0)
|
||||||
p = "/tmp";
|
p = "/";
|
||||||
|
else
|
||||||
|
p = "/tmp";
|
||||||
|
}
|
||||||
|
scopy(p, s);
|
||||||
|
strcat(s, "/trace");
|
||||||
}
|
}
|
||||||
scopy(p, s);
|
|
||||||
strcat(s, "/trace");
|
|
||||||
#else
|
#else
|
||||||
scopy("./trace", s);
|
scopy("./trace", s);
|
||||||
#endif /* not_this_way */
|
#endif /* not_this_way */
|
||||||
|
43
bin/sh/show.h
Normal file
43
bin/sh/show.h
Normal 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));
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,17 +38,22 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "nodes.h" /* for other headers */
|
#include "nodes.h" /* for other headers */
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
#include "jobs.h"
|
#include "jobs.h"
|
||||||
|
#include "show.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "syntax.h"
|
#include "syntax.h"
|
||||||
#include "output.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 "error.h"
|
||||||
#include "trap.h"
|
#include "trap.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -156,7 +159,7 @@ setsignal(signo)
|
|||||||
int signo;
|
int signo;
|
||||||
{
|
{
|
||||||
int action;
|
int action;
|
||||||
sig_t sigact;
|
sig_t sigact = SIG_DFL;
|
||||||
char *t;
|
char *t;
|
||||||
extern void onsig();
|
extern void onsig();
|
||||||
extern sig_t getsigaction();
|
extern sig_t getsigaction();
|
||||||
@ -235,7 +238,7 @@ getsigaction(signo)
|
|||||||
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
|
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
|
||||||
error("Sigaction system call failed");
|
error("Sigaction system call failed");
|
||||||
|
|
||||||
return sa.sa_handler;
|
return (sig_t) sa.sa_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,23 +35,17 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)trap.h 8.1 (Berkeley) 5/31/93
|
* @(#)trap.h 8.2 (Berkeley) 5/4/95
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int pendingsigs;
|
extern int pendingsigs;
|
||||||
|
|
||||||
#ifdef __STDC__
|
int trapcmd __P((int, char **));
|
||||||
void clear_traps(void);
|
void clear_traps __P((void));
|
||||||
long setsignal(int);
|
long setsignal __P((int));
|
||||||
void ignoresig(int);
|
sig_t getsigaction __P((int));
|
||||||
void dotrap(void);
|
void ignoresig __P((int));
|
||||||
void setinteractive(int);
|
void onsig __P((int));
|
||||||
void exitshell(int);
|
void dotrap __P((void));
|
||||||
#else
|
void setinteractive __P((int));
|
||||||
void clear_traps();
|
void exitshell __P((int));
|
||||||
long setsignal();
|
|
||||||
void ignoresig();
|
|
||||||
void dotrap();
|
|
||||||
void setinteractive();
|
|
||||||
void exitshell();
|
|
||||||
#endif
|
|
||||||
|
167
bin/sh/ulimit.c
167
bin/sh/ulimit.c
@ -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;
|
|
||||||
}
|
|
19
bin/sh/var.c
19
bin/sh/var.c
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -38,18 +38,19 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#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
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shell variables.
|
* Shell variables.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "expand.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 "memalloc.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "extern.h"
|
#ifndef NO_HISTORY
|
||||||
|
#include "myhistedit.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define VTABSIZE 39
|
#define VTABSIZE 39
|
||||||
@ -332,8 +335,8 @@ bltinlookup(name, doall)
|
|||||||
}
|
}
|
||||||
for (v = *hashvar(name) ; v ; v = v->next) {
|
for (v = *hashvar(name) ; v ; v = v->next) {
|
||||||
if (varequal(v->text, name)) {
|
if (varequal(v->text, name)) {
|
||||||
if (v->flags & VUNSET
|
if ((v->flags & VUNSET)
|
||||||
|| ! doall && (v->flags & VEXPORT) == 0)
|
|| (!doall && (v->flags & VEXPORT) == 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
return strchr(v->text, '=') + 1;
|
return strchr(v->text, '=') + 1;
|
||||||
}
|
}
|
||||||
|
45
bin/sh/var.h
45
bin/sh/var.h
@ -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
|
* Copyright (c) 1991, 1993
|
||||||
@ -35,7 +35,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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
|
#endif
|
||||||
#define mpathset() ((vmpath.flags & VUNSET) == 0)
|
#define mpathset() ((vmpath.flags & VUNSET) == 0)
|
||||||
|
|
||||||
|
void initvar __P((void));
|
||||||
#ifdef __STDC__
|
void setvar __P((char *, char *, int));
|
||||||
void initvar();
|
void setvareq __P((char *, int));
|
||||||
void setvar(char *, char *, int);
|
|
||||||
void setvareq(char *, int);
|
|
||||||
struct strlist;
|
struct strlist;
|
||||||
void listsetvar(struct strlist *);
|
void listsetvar __P((struct strlist *));
|
||||||
char *lookupvar(char *);
|
char *lookupvar __P((char *));
|
||||||
char *bltinlookup(char *, int);
|
char *bltinlookup __P((char *, int));
|
||||||
char **environment();
|
char **environment __P((void));
|
||||||
int showvarscmd(int, char **);
|
void shprocvar __P((void));
|
||||||
void mklocal(char *);
|
int showvarscmd __P((int, char **));
|
||||||
void poplocalvars(void);
|
int exportcmd __P((int, char **));
|
||||||
int unsetcmd(int, char **);
|
int localcmd __P((int, char **));
|
||||||
#else
|
void mklocal __P((char *));
|
||||||
void initvar();
|
void poplocalvars __P((void));
|
||||||
void setvar();
|
int setvarcmd __P((int, char **));
|
||||||
void setvareq();
|
int unsetcmd __P((int, char **));
|
||||||
void listsetvar();
|
|
||||||
char *lookupvar();
|
|
||||||
char *bltinlookup();
|
|
||||||
char **environment();
|
|
||||||
int showvarscmd();
|
|
||||||
void mklocal();
|
|
||||||
void poplocalvars();
|
|
||||||
int unsetcmd();
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user