This commit was generated by cvs2svn to compensate for changes in r76, which

included commits to RCS files with non-trunk default branches.
This commit is contained in:
tg 2003-12-22 20:22:51 +00:00
commit 18ea554a22
16 changed files with 89 additions and 65 deletions

4
NOTES
View File

@ -1,4 +1,4 @@
$OpenBSD: NOTES,v 1.8 2003/02/26 03:53:35 david Exp $ $OpenBSD: NOTES,v 1.9 2003/10/26 15:07:25 jmc Exp $
General features of at&t ksh88 that are not (yet) in pdksh: General features of at&t ksh88 that are not (yet) in pdksh:
- exported aliases and functions (not in ksh93). - exported aliases and functions (not in ksh93).
@ -131,7 +131,7 @@ Known differences between pdksh & at&t ksh (that are not likely to change)
- . file: at&t ksh parses the whole file before executing anything, - . file: at&t ksh parses the whole file before executing anything,
pdksh executes as it parses. This means aliases defined in the file pdksh executes as it parses. This means aliases defined in the file
will affect how pdksh parses the file, but won't affect how at&t ksh will affect how pdksh parses the file, but won't affect how at&t ksh
parses the file. Also means pdksh will not parse statements occuring parses the file. Also means pdksh will not parse statements occurring
after a (executed) return statement. after a (executed) return statement.
- a return in $ENV in at&t ksh will cause the shell to exit, while in - a return in $ENV in at&t ksh will cause the shell to exit, while in
pdksh it will stop executing the script (this is consistent with pdksh it will stop executing the script (this is consistent with

View File

@ -1,4 +1,4 @@
/* $OpenBSD: c_ksh.c,v 1.16 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: c_ksh.c,v 1.17 2003/10/22 07:40:38 jmc Exp $ */
/* /*
* built-in Korn commands: c_* * built-in Korn commands: c_*
@ -75,7 +75,7 @@ c_cd(wp)
bi_errorf("don't know current directory"); bi_errorf("don't know current directory");
return 1; return 1;
} }
/* substitue arg1 for arg2 in current path. /* substitute arg1 for arg2 in current path.
* if the first substitution fails because the cd fails * if the first substitution fails because the cd fails
* we could try to find another substitution. For now * we could try to find another substitution. For now
* we don't * we don't
@ -652,7 +652,7 @@ c_typeset(wp)
flag = LCASEV; flag = LCASEV;
break; break;
case 'p': /* posix export/readonly -p flag. case 'p': /* posix export/readonly -p flag.
* typset -p is the same as typeset (in pdksh); * typeset -p is the same as typeset (in pdksh);
* here for compatibility with ksh93. * here for compatibility with ksh93.
*/ */
pflag = 1; pflag = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: c_test.c,v 1.9 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */
/* /*
* test(1); version 7-like -- author Erik Baalbergen * test(1); version 7-like -- author Erik Baalbergen
@ -458,10 +458,12 @@ test_eaccess(path, mode)
} }
#endif /* !HAVE_DEV_FD */ #endif /* !HAVE_DEV_FD */
/* On most (all?) unixes, access() says everything is executable for res = eaccess(path, mode);
/*
* On most (all?) unixes, access() says everything is executable for
* root - avoid this on files by using stat(). * root - avoid this on files by using stat().
*/ */
if ((mode & X_OK) && ksheuid == 0) { if (res == 0 && ksheuid == 0 && (mode & X_OK)) {
struct stat statb; struct stat statb;
if (stat(path, &statb) < 0) if (stat(path, &statb) < 0)
@ -471,13 +473,7 @@ test_eaccess(path, mode)
else else
res = (statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) res = (statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))
? 0 : -1; ? 0 : -1;
/* Need to check other permissions? If so, use access() as }
* this will deal with root on NFS.
*/
if (res == 0 && (mode & (R_OK|W_OK)))
res = eaccess(path, mode);
} else
res = eaccess(path, mode);
return res; return res;
} }

View File

@ -1,7 +1,7 @@
/* $OpenBSD: c_test.h,v 1.1.1.1 1996/08/14 06:19:10 downsj Exp $ */ /* $OpenBSD: c_test.h,v 1.2 2003/10/22 07:40:38 jmc Exp $ */
/* Various types of operations. Keeping things grouped nicely /* Various types of operations. Keeping things grouped nicely
* (unary,binary) makes switch() statements more efficeint. * (unary,binary) makes switch() statements more efficient.
*/ */
enum Test_op { enum Test_op {
TO_NONOP = 0, /* non-operator */ TO_NONOP = 0, /* non-operator */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: config.h,v 1.8 2003/05/16 18:49:46 jsyn Exp $ */ /* $OpenBSD: config.h,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/* config.h. NOT generated automatically. */ /* config.h. NOT generated automatically. */
@ -76,7 +76,7 @@
/* Define if the closedir function returns void instead of int. */ /* Define if the closedir function returns void instead of int. */
/* #undef VOID_CLOSEDIR */ /* #undef VOID_CLOSEDIR */
/* Define if your kernal doesn't handle scripts starting with #! */ /* Define if your kernel doesn't handle scripts starting with #! */
/* #undef SHARPBANG */ /* #undef SHARPBANG */
/* Define if dup2() preserves the close-on-exec flag (ultrix does this) */ /* Define if dup2() preserves the close-on-exec flag (ultrix does this) */

8
eval.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: eval.c,v 1.13 2003/04/16 23:11:52 tdeval Exp $ */ /* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */
/* /*
* Expansion - quoting, separation, substitution, globbing * Expansion - quoting, separation, substitution, globbing
@ -874,8 +874,10 @@ comsub(xp, cp)
openpipe(pv); openpipe(pv);
shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0); shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */ ofd1 = savefd(1, 0); /* fd 1 may be closed... */
ksh_dup2(pv[1], 1, FALSE); if (pv[1] != 1) {
close(pv[1]); ksh_dup2(pv[1], 1, FALSE);
close(pv[1]);
}
execute(t, XFORK|XXCOM|XPIPEO); execute(t, XFORK|XXCOM|XPIPEO);
restfd(1, ofd1); restfd(1, ofd1);
startlast(); startlast();

20
exec.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: exec.c,v 1.27 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/* /*
* execute command tree * execute command tree
@ -230,8 +230,10 @@ execute(t, flags)
e->savefd[1] = savefd(1, 0); e->savefd[1] = savefd(1, 0);
openpipe(pv); openpipe(pv);
ksh_dup2(pv[0], 0, FALSE); if (pv[0] != 0) {
close(pv[0]); ksh_dup2(pv[0], 0, FALSE);
close(pv[0]);
}
coproc.write = pv[1]; coproc.write = pv[1];
coproc.job = (void *) 0; coproc.job = (void *) 0;
@ -457,11 +459,12 @@ comexec(t, tp, ap, flags)
int type_flags; int type_flags;
int keepasn_ok; int keepasn_ok;
int fcflags = FC_BI|FC_FUNC|FC_PATH; int fcflags = FC_BI|FC_FUNC|FC_PATH;
int bourne_function_call = 0;
#ifdef KSH #ifdef KSH
/* snag the last argument for $_ XXX not the same as at&t ksh, /* snag the last argument for $_ XXX not the same as at&t ksh,
* which only seems to set $_ after a newline (but not in * which only seems to set $_ after a newline (but not in
* functions/dot scripts, but in interactive and scipt) - * functions/dot scripts, but in interactive and script) -
* perhaps save last arg here and set it in shell()?. * perhaps save last arg here and set it in shell()?.
*/ */
if (!Flag(FSH) && Flag(FTALKING) && *(lastp = ap)) { if (!Flag(FSH) && Flag(FTALKING) && *(lastp = ap)) {
@ -546,9 +549,10 @@ comexec(t, tp, ap, flags)
newblock(); newblock();
/* ksh functions don't keep assignments, POSIX functions do. */ /* ksh functions don't keep assignments, POSIX functions do. */
if (keepasn_ok && tp && tp->type == CFUNC if (keepasn_ok && tp && tp->type == CFUNC
&& !(tp->flag & FKSH)) && !(tp->flag & FKSH)) {
bourne_function_call = 1;
type_flags = 0; type_flags = 0;
else } else
type_flags = LOCAL|LOCAL_COPY|EXPORT; type_flags = LOCAL|LOCAL_COPY|EXPORT;
} }
if (Flag(FEXPORT)) if (Flag(FEXPORT))
@ -565,6 +569,8 @@ comexec(t, tp, ap, flags)
shf_flush(shl_out); shf_flush(shl_out);
} }
typeset(cp, type_flags, 0, 0, 0); typeset(cp, type_flags, 0, 0, 0);
if (bourne_function_call && !(type_flags & EXPORT))
typeset(cp, LOCAL|LOCAL_COPY|EXPORT, 0, 0, 0);
} }
if ((cp = *ap) == NULL) { if ((cp = *ap) == NULL) {
@ -1355,6 +1361,8 @@ iosetup(iop, tp)
snptreef((char *) 0, 32, "%R", &iotmp), emsg); snptreef((char *) 0, 32, "%R", &iotmp), emsg);
return -1; return -1;
} }
if (u == iop->unit)
return 0; /* "dup from" == "dup to" */
break; break;
} }
} }

8
expr.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: expr.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/* /*
* Korn expression evaluation * Korn expression evaluation
@ -140,7 +140,7 @@ static struct tbl *tempvar ARGS((void));
static struct tbl *intvar ARGS((Expr_state *es, struct tbl *vp)); static struct tbl *intvar ARGS((Expr_state *es, struct tbl *vp));
/* /*
* parse and evalute expression * parse and evaluate expression
*/ */
int int
evaluate(expr, rval, error_ok) evaluate(expr, rval, error_ok)
@ -159,7 +159,7 @@ evaluate(expr, rval, error_ok)
} }
/* /*
* parse and evalute expression, storing result in vp. * parse and evaluate expression, storing result in vp.
*/ */
int int
v_evaluate(vp, expr, error_ok) v_evaluate(vp, expr, error_ok)
@ -208,7 +208,7 @@ v_evaluate(vp, expr, error_ok)
if (vp->flag & INTEGER) if (vp->flag & INTEGER)
setint_v(vp, v); setint_v(vp, v);
else else
/* can fail if readony */ /* can fail if readonly */
setstr(vp, str_val(v), error_ok); setstr(vp, str_val(v), error_ok);
quitenv(); quitenv();

4
io.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: io.c,v 1.12 2003/03/10 03:48:16 david Exp $ */ /* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/* /*
* shell buffered IO and formatted output * shell buffered IO and formatted output
@ -321,7 +321,7 @@ restfd(fd, ofd)
shf_flush(&shf_iob[fd]); shf_flush(&shf_iob[fd]);
if (ofd < 0) /* original fd closed */ if (ofd < 0) /* original fd closed */
close(fd); close(fd);
else { else if (fd != ofd) {
ksh_dup2(ofd, fd, TRUE); /* XXX: what to do if this fails? */ ksh_dup2(ofd, fd, TRUE); /* XXX: what to do if this fails? */
close(ofd); close(ofd);
} }

14
jobs.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: jobs.c,v 1.19 2003/03/13 09:03:07 deraadt Exp $ */ /* $OpenBSD: jobs.c,v 1.21 2003/11/10 21:26:39 millert Exp $ */
/* /*
* Process and job control * Process and job control
@ -15,7 +15,7 @@
* *
* Notes regarding the copious ifdefs: * Notes regarding the copious ifdefs:
* - JOB_SIGS is independent of JOBS - it is defined if there are modern * - JOB_SIGS is independent of JOBS - it is defined if there are modern
* signal and wait routines available. This is prefered, even when * signal and wait routines available. This is preferred, even when
* JOBS is not defined, since the shell will not otherwise notice when * JOBS is not defined, since the shell will not otherwise notice when
* background jobs die until the shell waits for a foreground process * background jobs die until the shell waits for a foreground process
* to die. * to die.
@ -123,7 +123,7 @@ struct proc {
#define JF_CHANGED 0x040 /* process has changed state */ #define JF_CHANGED 0x040 /* process has changed state */
#define JF_KNOWN 0x080 /* $! referenced */ #define JF_KNOWN 0x080 /* $! referenced */
#define JF_ZOMBIE 0x100 /* known, unwaited process */ #define JF_ZOMBIE 0x100 /* known, unwaited process */
#define JF_REMOVE 0x200 /* flaged for removal (j_jobs()/j_noityf()) */ #define JF_REMOVE 0x200 /* flagged for removal (j_jobs()/j_noityf()) */
#define JF_USETTYMODE 0x400 /* tty mode saved if process exits normally */ #define JF_USETTYMODE 0x400 /* tty mode saved if process exits normally */
#define JF_SAVEDTTYPGRP 0x800 /* j->saved_ttypgrp is valid */ #define JF_SAVEDTTYPGRP 0x800 /* j->saved_ttypgrp is valid */
@ -629,8 +629,10 @@ exchild(t, flags, close_fd)
SS_RESTORE_IGN|SS_FORCE); SS_RESTORE_IGN|SS_FORCE);
if (!(flags & (XPIPEI | XCOPROC))) { if (!(flags & (XPIPEI | XCOPROC))) {
int fd = open("/dev/null", 0); int fd = open("/dev/null", 0);
(void) ksh_dup2(fd, 0, TRUE); if (fd != 0) {
close(fd); (void) ksh_dup2(fd, 0, TRUE);
close(fd);
}
} }
} }
remove_job(j, "child"); /* in case of `jobs` command */ remove_job(j, "child"); /* in case of `jobs` command */
@ -1435,7 +1437,7 @@ check_job(j)
*/ */
if (j->state == PEXITED || j->state == PSIGNALLED) { if (j->state == PEXITED || j->state == PSIGNALLED) {
/* No need to keep co-process input any more /* No need to keep co-process input any more
* (at leasst, this is what ksh93d thinks) * (at least, this is what ksh93d thinks)
*/ */
if (coproc.job == j) { if (coproc.job == j) {
coproc.job = (void *) 0; coproc.job = (void *) 0;

4
path.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: path.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: path.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
#include "sh.h" #include "sh.h"
#include "ksh_stat.h" #include "ksh_stat.h"
@ -29,7 +29,7 @@ static char *do_phys_path ARGS((XString *xsp, char *xp, const char *path));
* - cdpathp is set to the start of the next element in cdpathp (or NULL * - cdpathp is set to the start of the next element in cdpathp (or NULL
* if there are no more elements. * if there are no more elements.
* The return value indicates whether a non-null element from cdpathp * The return value indicates whether a non-null element from cdpathp
* was appened to result. * was appended to result.
*/ */
int int
make_path(cwd, file, cdpathp, xsp, phys_pathp) make_path(cwd, file, cdpathp, xsp, phys_pathp)

48
sh.1tbl
View File

@ -1,4 +1,4 @@
.\" $OpenBSD: sh.1tbl,v 1.36 2003/09/04 14:21:43 jmc Exp $ .\" $OpenBSD: sh.1tbl,v 1.40 2003/12/22 11:54:02 jmc Exp $
.\" .\"
.\" Copyright (c) 1980, 1990, 1993 .\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -400,6 +400,19 @@ have equal precedence which is higher than that of
and and
.Ql \&; , .Ql \&; ,
which also have equal precedence. which also have equal precedence.
Note that the
.Ql &&
and
.Ql ||
operators are
.Qq left-associative .
For example, both of these commands will print only
.Qq bar :
.Bd -literal -offset indent
false && echo foo || echo bar
true || echo foo && echo bar
.Ed
.Pp
The The
.Ql & .Ql &
token causes the preceding command to be executed asynchronously; that is, token causes the preceding command to be executed asynchronously; that is,
@ -2069,7 +2082,10 @@ loop
.It .It
.Ic alias a='for ' i='j' .Ic alias a='for ' i='j'
.It .It
.Ic a i in 1 2; do echo i=$i j=$j; done .Xo
.Ic a i in 1 2; do echo i=$i j=$j;
.Ic done
.Xc
.El .El
.Pp .Pp
uses parameter uses parameter
@ -2142,7 +2158,7 @@ Additional ksh special commands
Very special commands Very special commands
.Pq Pf non- Tn POSIX .Pq Pf non- Tn POSIX
.Pp .Pp
.Ic alias , readonly , set , typset .Ic alias , readonly , set , typeset
.Pp .Pp
.Tn POSIX .Tn POSIX
regular commands regular commands
@ -3784,6 +3800,19 @@ extensions exposed, caution should be used where backwards compatibility with
traditional Bourne or traditional Bourne or
.Tn POSIX .Tn POSIX
compliant shells is an issue. compliant shells is an issue.
.Sh AUTHORS
This shell is based on the public domain 7th edition Bourne shell clone by
Charles Forsyth and parts of the BRL shell by Doug A. Gwyn, Doug Kingston,
Ron Natalie, Arnold Robbins, Lou Salkind, and others.
The first release of
.Nm pdksh
was created by Eric Gisin, and it was subsequently maintained by John R.
MacMillan (change!john@sq.sq.com) and Simon J. Gerraty (sjg@zen.void.oz.au).
The current maintainer is Michael Rendell (michael@cs.mun.ca).
The
.Pa CONTRIBUTORS
file in the source distribution contains a more complete list of people and
their part in the shell's development.
.Sh BUGS .Sh BUGS
Any bugs in Any bugs in
.Nm pdksh .Nm pdksh
@ -3816,16 +3845,3 @@ echo hi | read a; echo $a\ \ \ # Does not print hi
.Ed .Ed
.Pp .Pp
I'm aware of this and there is no need to report it. I'm aware of this and there is no need to report it.
.Sh AUTHORS
This shell is based on the public domain 7th edition Bourne shell clone by
Charles Forsyth and parts of the BRL shell by Doug A. Gwyn, Doug Kingston,
Ron Natalie, Arnold Robbins, Lou Salkind, and others.
The first release of
.Nm pdksh
was created by Eric Gisin, and it was subsequently maintained by John R.
MacMillan (change!john@sq.sq.com) and Simon J. Gerraty (sjg@zen.void.oz.au).
The current maintainer is Michael Rendell (michael@cs.mun.ca).
The
.Pa CONTRIBUTORS
file in the source distribution contains a more complete list of people and
their part in the shell's development.

4
syn.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: syn.c,v 1.13 2002/06/09 05:47:27 todd Exp $ */ /* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */
/* /*
* shell parser (C version) * shell parser (C version)
@ -571,7 +571,7 @@ function_body(name, ksh_func)
/* /*
* Probably something like foo() followed by eof or ;. * Probably something like foo() followed by eof or ;.
* This is accepted by sh and ksh88. * This is accepted by sh and ksh88.
* To make "typset -f foo" work reliably (so its output can * To make "typeset -f foo" work reliably (so its output can
* be used as input), we pretend there is a colon here. * be used as input), we pretend there is a colon here.
*/ */
t->left = newtp(TCOM); t->left = newtp(TCOM);

View File

@ -19,7 +19,7 @@ description:
category: !os:os2 category: !os:os2
file-setup: dir 755 "dir" file-setup: dir 755 "dir"
file-setup: symlink 644 "dir/abc" file-setup: symlink 644 "dir/abc"
non-existant-file non-existent-file
stdin: stdin:
echo d*/* echo d*/*
echo d*/abc echo d*/abc

View File

@ -1,4 +1,4 @@
# $OpenBSD: regress.t,v 1.11 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: regress.t,v 1.12 2003/11/08 19:17:27 jmc Exp $
# #
# The first 39 of these tests are from the old Bugs script. # The first 39 of these tests are from the old Bugs script.
@ -290,7 +290,7 @@ description:
The command The command
. /foo/bar . /foo/bar
should set the exit status to non-zero (sh and at&t ksh88 do). should set the exit status to non-zero (sh and at&t ksh88 do).
XXX doting a non existant file is a fatal error for a script XXX doting a non existent file is a fatal error for a script
stdin: stdin:
. does/not/exist . does/not/exist
expected-exit: e != 0 expected-exit: e != 0

4
tree.h
View File

@ -1,4 +1,4 @@
/* $OpenBSD: tree.h,v 1.7 1999/07/14 13:37:24 millert Exp $ */ /* $OpenBSD: tree.h,v 1.8 2003/10/22 07:40:38 jmc Exp $ */
/* /*
* command trees for compile/execute * command trees for compile/execute
@ -109,7 +109,7 @@ struct ioword {
#define XCCLOSE BIT(7) /* exchild: close close_fd in child */ #define XCCLOSE BIT(7) /* exchild: close close_fd in child */
#define XERROK BIT(8) /* non-zero exit ok (for set -e) */ #define XERROK BIT(8) /* non-zero exit ok (for set -e) */
#define XCOPROC BIT(9) /* starting a co-process */ #define XCOPROC BIT(9) /* starting a co-process */
#define XTIME BIT(10) /* timeing TCOM command */ #define XTIME BIT(10) /* timing TCOM command */
#define XINTACT BIT(11) /* OS2: proc started from interactive session */ #define XINTACT BIT(11) /* OS2: proc started from interactive session */
/* /*