diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-11-21 07:59:41 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-11-21 07:59:41 +0000 |
commit | e7ba2dde1be71475ca9e13475a5da793e6e71492 (patch) | |
tree | 92fc7d77b93be740bc71187341a0164e93242b61 /bin/ksh | |
parent | 348b1798b3067a1b3e79d9460d7f51a07ccd44ef (diff) |
Update to 5.2.12.
Diffstat (limited to 'bin/ksh')
-rw-r--r-- | bin/ksh/BUG-REPORTS | 29 | ||||
-rw-r--r-- | bin/ksh/ChangeLog | 56 | ||||
-rw-r--r-- | bin/ksh/IAFA-PACKAGE | 4 | ||||
-rw-r--r-- | bin/ksh/NEWS | 17 | ||||
-rw-r--r-- | bin/ksh/README | 7 | ||||
-rw-r--r-- | bin/ksh/c_ksh.c | 8 | ||||
-rw-r--r-- | bin/ksh/exec.c | 5 | ||||
-rw-r--r-- | bin/ksh/jobs.c | 48 | ||||
-rw-r--r-- | bin/ksh/ksh.1 | 9 | ||||
-rw-r--r-- | bin/ksh/ksh.1tbl | 9 | ||||
-rw-r--r-- | bin/ksh/lex.c | 3 | ||||
-rw-r--r-- | bin/ksh/main.c | 71 | ||||
-rw-r--r-- | bin/ksh/proto.h | 3 | ||||
-rw-r--r-- | bin/ksh/syn.c | 10 | ||||
-rw-r--r-- | bin/ksh/table.h | 7 | ||||
-rw-r--r-- | bin/ksh/tests/history.t | 2 | ||||
-rw-r--r-- | bin/ksh/tests/regress.t | 90 | ||||
-rw-r--r-- | bin/ksh/tests/th.sh | 1 | ||||
-rw-r--r-- | bin/ksh/tests/version.t | 2 | ||||
-rw-r--r-- | bin/ksh/tty.h | 24 | ||||
-rw-r--r-- | bin/ksh/version.c | 4 | ||||
-rw-r--r-- | bin/ksh/vi.c | 9 |
22 files changed, 342 insertions, 76 deletions
diff --git a/bin/ksh/BUG-REPORTS b/bin/ksh/BUG-REPORTS index 7c6cc24c41d..1295a31fefb 100644 --- a/bin/ksh/BUG-REPORTS +++ b/bin/ksh/BUG-REPORTS @@ -1,4 +1,4 @@ -$OpenBSD: BUG-REPORTS,v 1.4 1996/10/13 21:32:15 downsj Exp $ +$OpenBSD: BUG-REPORTS,v 1.5 1996/11/21 07:59:24 downsj Exp $ List of reported problems (problems reported and fixed before 5.0.4 not included). Unresolved problems (may or may not still exist) marked by *, @@ -1088,3 +1088,30 @@ x pdksh 5.2.10, - (reported by Dale DePriest): expanding aliases causes [see Mail.XXX] [fixed in 5.2.11: fixed syn.c(c_list).] +x pdksh 5.2.10, - (reported by John Rochester): window size changes don't + happen on Dec unix (osf) because TIOCGWINSZ is defined in <sys/ioctl.h> + not in <termios.h>. + [see Mail.XXX] + [fixed in 5.2.12: sys/ioctl.h included with termios.h/termio.h if possible] + +x pdksh 5.2.11, - (reported by Randy Bouzane): aliases in command substitutions + result in code dumps. + [see Mail.XXX] + [fixed in 5.2.12: lex.c(getsc__): break if eof is read] + +x pdksh 5.2.11, - (reported by Will Renkel): aliases containing ;<newline> + or <newline><newline> aren't fully read/executed. + [see Mail.XXX] + [fixed in 5.2.12: syn.c(get_command): call inalias()] + +x pdksh 5.2.11, SGI/IRIX 5.2 (reported by bert@xpilot.com): pipelines + containing built in commands hang forever. + [see Mail.XXX] + [fixed in 5.2.12: fixed pgrp sync code in jobs.c] + +x pdksh 5.2.11, - (reported by Herbert Thielen via Larry Daffner): shell leaves + temp files around when executing shell scripts that have functions with + here documents which end in an exec. + [see Mail.XXX] + [fixed in 5.2.12: call main.c(cleanup_proc_env()) from exec.c(execute()).] + diff --git a/bin/ksh/ChangeLog b/bin/ksh/ChangeLog index 23c1442e316..b515993f3aa 100644 --- a/bin/ksh/ChangeLog +++ b/bin/ksh/ChangeLog @@ -1,4 +1,58 @@ -$OpenBSD: ChangeLog,v 1.4 1996/10/13 21:32:16 downsj Exp $ +$OpenBSD: ChangeLog,v 1.5 1996/11/21 07:59:25 downsj Exp $ + +Tue Oct 29 11:34:58 NST 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * made pdksh-5.2.12 distribution + +Fri Oct 25 11:59:48 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * vi.c(vi_cmd): case Cntl('i'): dont fall through, call complete_word(). + +Tue Oct 22 17:38:21 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * table.h(USERATTRIB): new define. + * c_ksh.c(c_typeset): report unset params only if it has some + interesting attributes. + +Tue Oct 22 15:54:39 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * jobs.c(exchild): changed NEED_PGRP_SYNC code so j_sync_pipe[1] isn't + left open in 2nd+ children. + +Tue Oct 22 12:59:49 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * main.c(main): memset() env to 0. + +Mon Oct 21 12:53:44 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * main.c(cleanup_proc_env): new function. + * exec.c(execute): call cleanup_proc_env() before calling ksh_execve(). + +Fri Oct 11 22:53:57 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * vi.c(display): use ch not e->buf[cur] when printing character. + +Fri Oct 11 13:26:11 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4(KSH_TIMES_CHECK,KSH_DUP2_CLEXEC_CHECK,KSH_OPENDIR_CHECK): + changed sense of test so "yes" result is printed if you have a good + system. + * aclocal.m4(KSH_C_FUNC_ATTR): changed return type of test_cnst to int. + +Fri Oct 11 13:05:40 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * syn.c(get_command): added inalias() call when setting cf = CONTIN. + +Thu Oct 10 16:22:03 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * lex.c(getsc__): case SALIAS: if we read eof, break, don't continue. + +Tue Oct 8 13:14:00 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4(KSH_TERM): added SYS_IOCTL_WITH_TERMIOS, + SYS_IOCTL_WITH_TERMIO tests. + * tty.h: include <sys/ioctl.h> with <termios.h>/<termio.h> + if possible. Tue Oct 8 11:42:36 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) diff --git a/bin/ksh/IAFA-PACKAGE b/bin/ksh/IAFA-PACKAGE index 4ef2c92384f..879682c0a61 100644 --- a/bin/ksh/IAFA-PACKAGE +++ b/bin/ksh/IAFA-PACKAGE @@ -1,7 +1,7 @@ -$OpenBSD: IAFA-PACKAGE,v 1.4 1996/10/13 21:32:17 downsj Exp $ +$OpenBSD: IAFA-PACKAGE,v 1.5 1996/11/21 07:59:25 downsj Exp $ Title: pdksh -Version: 5.2.11 +Version: 5.2.12 Description: A public domain implementation of the Korn shell (ksh88), a UNIX command line interpreter / scripting language; the few missing ksh features are being added and the shell is being diff --git a/bin/ksh/NEWS b/bin/ksh/NEWS index bf29902103e..f1115015719 100644 --- a/bin/ksh/NEWS +++ b/bin/ksh/NEWS @@ -1,4 +1,19 @@ -$OpenBSD: NEWS,v 1.4 1996/10/13 21:32:17 downsj Exp $ +$OpenBSD: NEWS,v 1.5 1996/11/21 07:59:26 downsj Exp $ + +Version 5.2.12 + +* bug fixes + * editing: shell recognizes window resizes on Dec alphas (config problem). + * alias: no longer dumps core if alias is in a command substitution. + * alias: everything after ;\n or \n\n was ignored in aliases. + * exec: temp files used by here docs in functions now cleaned up on exec. + * possible core dump when cleaning up environment fixed. + * vi: set -o vi-show8 now does what it was supposed to do (cat -v like). + * job control: process group synchronization (needed on systems with + broken setpgrp()) now works when the pipeline contains built in commands. + * vi: if set -o vi-tabcomplete, tab works in command mode as well. + * set/typeset: unset parameters are only reported if they have attributes. + Version 5.2.11 diff --git a/bin/ksh/README b/bin/ksh/README index 7e0c9015a89..f12f85b0ede 100644 --- a/bin/ksh/README +++ b/bin/ksh/README @@ -1,6 +1,6 @@ -$OpenBSD: README,v 1.4 1996/10/13 21:32:18 downsj Exp $ +$OpenBSD: README,v 1.5 1996/11/21 07:59:26 downsj Exp $ -Last updated October '96 for pdksh-5.2.11. +Last updated October '96 for pdksh-5.2.12. (check ftp://ftp.cs.mun.ca:/pub/pdksh/ or http://www.cs.mun.ca/~michael/pdksh/ for new versions/patches) @@ -129,7 +129,7 @@ Compiling/Installing: to pass/fail, and PASS/FAIL for tests it expected to fail/pass. If you don't have perl, or if your perl doesn't work (most common problem is the .ph header files are missing or broken), you can run - misc/Bugs path-to-pdksh-executable + ENV= path-to-pdksh-executable misc/Bugs path-to-pdksh-executable instead. * run make install: this installs ksh (in /usr/local/bin/ksh by default, or where ever you told configure to put things). @@ -157,6 +157,7 @@ The following is a list of machines that pdksh is reported to work on: IBM/RS/6000 AIX 3.2.5 MIPS/m120 RISC/os 5.0 (bsd43 environ) NeXT NeXTStep 3.2 + SGI/IRIX 6.2 Sun/sun4 SunOS 4.1.3, 4.1.4 Sun/sun4 Solaris 2.x Sun/sun386i SunOS 4.0.2 diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c index a08ec31ae1c..df402d54e1b 100644 --- a/bin/ksh/c_ksh.c +++ b/bin/ksh/c_ksh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ksh.c,v 1.4 1996/10/01 02:05:32 downsj Exp $ */ +/* $OpenBSD: c_ksh.c,v 1.5 1996/11/21 07:59:27 downsj Exp $ */ /* * built-in Korn commands: c_* @@ -768,6 +768,12 @@ c_typeset(wp) for (l = e->loc; l; l = l->next) { for (p = tsort(&l->vars); (vp = *p++); ) for (; vp; vp = vp->u.array) { + /* Report an unset param only if the user has + * explicitly given it some attribute (like export); + * otherwise, after "echo $FOO", we would report FOO... + */ + if (!(vp->flag & ISSET) && !(vp->flag & USERATTRIB)) + continue; if (flag && (vp->flag & flag) == 0) continue; /* no arguments */ diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c index 345b68df31a..15027419bef 100644 --- a/bin/ksh/exec.c +++ b/bin/ksh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.4 1996/10/01 02:05:34 downsj Exp $ */ +/* $OpenBSD: exec.c,v 1.5 1996/11/21 07:59:28 downsj Exp $ */ /* * execute command tree @@ -34,7 +34,7 @@ static int dbteste_eval ARGS((Test_env *te, Test_op op, const char *opnd1, static void dbteste_error ARGS((Test_env *te, int offset, const char *msg)); #endif /* KSH */ #ifdef OS2 -static int search_access1 ARGS((const char *path, int mode)); +static int search_access1 ARGS((const char *path, int mode, int *errnop)); #endif /* OS2 */ @@ -417,6 +417,7 @@ execute(t, flags) } #endif restoresigs(); + cleanup_proc_env(); ksh_execve(t->str, t->args, ap); if (errno == ENOEXEC) scriptexec(t, ap); diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c index ec68bff518b..2b7369df085 100644 --- a/bin/ksh/jobs.c +++ b/bin/ksh/jobs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jobs.c,v 1.3 1996/08/25 12:38:03 downsj Exp $ */ +/* $OpenBSD: jobs.c,v 1.4 1996/11/21 07:59:29 downsj Exp $ */ /* * Process and job control @@ -464,9 +464,9 @@ exchild(t, flags, close_fd) last_proc = p; } else { #ifdef NEED_PGRP_SYNC - if (j_sync_open) { - closepipe(j_sync_pipe); + if (j_sync_open) { /* should never happen */ j_sync_open = 0; + closepipe(j_sync_pipe); } /* don't do the sync pipe business if there is no pipeline */ if (flags & XPIPEO) { @@ -529,19 +529,31 @@ exchild(t, flags, close_fd) if (Flag(FMONITOR) && !(flags&XXCOM)) { int dotty = 0; # ifdef NEED_PGRP_SYNC - int dosync = 0; + int first_child_sync = 0; # endif /* NEED_PGRP_SYNC */ - if (j->pgrp == 0) { /* First process */ - j->pgrp = p->pid; - dotty = 1; # ifdef NEED_PGRP_SYNC - if (j_sync_open) { + if (j_sync_open) { + /* + * The Parent closes 0, keeps 1 open 'til the whole + * pipeline is started. The First child closes 1, + * keeps 0 open (reads from it). The remaining + * children just have to close 1 (parent has already + * closeed 0). + */ + if (j->pgrp == 0) { /* First process */ close(j_sync_pipe[ischild]); j_sync_pipe[ischild] = -1; - dosync = ischild; + first_child_sync = ischild; + } else if (ischild) { + j_sync_open = 0; + closepipe(j_sync_pipe); } + } # endif /* NEED_PGRP_SYNC */ + if (j->pgrp == 0) { /* First process */ + j->pgrp = p->pid; + dotty = 1; } /* set pgrp in both parent and child to deal with race @@ -558,13 +570,11 @@ exchild(t, flags, close_fd) tcsetpgrp(tty_fd, j->pgrp); # endif /* TTY_PGRP */ # ifdef NEED_PGRP_SYNC - if (ischild && j_sync_open) { - if (dosync) { - char c; - while (read(j_sync_pipe[0], &c, 1) == -1 - && errno == EINTR) - ; - } + if (first_child_sync) { + char c; + while (read(j_sync_pipe[0], &c, 1) == -1 + && errno == EINTR) + ; close(j_sync_pipe[0]); j_sync_open = 0; } @@ -1121,14 +1131,14 @@ j_startjob(j) #ifdef NEED_PGRP_SYNC if (j_sync_open) { - closepipe(j_sync_pipe); j_sync_open = 0; + closepipe(j_sync_pipe); } #endif /* NEED_PGRP_SYNC */ #ifdef JOB_SIGS if (held_sigchld) { held_sigchld = 0; - /* Don't call j_sigchild() as it may remove job... */ + /* Don't call j_sigchld() as it may remove job... */ kill(procpid, SIGCHLD); } #endif /* JOB_SIGS */ @@ -1344,7 +1354,7 @@ found: /* * Called only when a process in j has exited/stopped (ie, called only - * from j_sigchild()). If no processes are running, the job status + * from j_sigchld()). If no processes are running, the job status * and state are updated, asynchronous job notification is done and, * if unneeded, the job is removed. * diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1 index 9a1d313a355..f9118ca871e 100644 --- a/bin/ksh/ksh.1 +++ b/bin/ksh/ksh.1 @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: ksh.1,v 1.1 1996/10/01 09:05:21 downsj Exp $ +.\" $OpenBSD: ksh.1,v 1.2 1996/11/21 07:59:30 downsj Exp $ .\"{{{}}} .\"{{{ Notes about man page .\" - use the pseudo-macros .sh( and .sh) to begin and end sh-specific @@ -1822,9 +1822,10 @@ If the input line ends in a backslash and the \fB\-r\fP option was not used, the backslash and newline are stripped and more input is read. If no input is read, \fBread\fP exits with a non-zero status. .sp -A prompt, which is printed to standard error before any input is read, may be -specified by appending and question mark and the prompt to the -first parameter (\fIe.g.\fP, \fBread nfoo?'number of foos: '\fP). +The first parameter may have a question mark and a string appended to it, in +which case the string is used as a prompt (printed to standard error before +any input is read) if the input is a tty +(\fIe.g.\fP, \fBread nfoo?'number of foos: '\fP). .sp The \fB\-u\fP\fIn\fP and \fB\-p\fP options cause input to be read from file descriptor \fIn\fP or the current co-process (see Co-Processes above diff --git a/bin/ksh/ksh.1tbl b/bin/ksh/ksh.1tbl index b64e70c1196..2a7879a72e8 100644 --- a/bin/ksh/ksh.1tbl +++ b/bin/ksh/ksh.1tbl @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: ksh.1tbl,v 1.1 1996/10/01 09:05:21 downsj Exp $ +.\" $OpenBSD: ksh.1tbl,v 1.2 1996/11/21 07:59:30 downsj Exp $ .\"{{{}}} .\"{{{ Notes about man page .\" - use the pseudo-macros .sh( and .sh) to begin and end sh-specific @@ -1822,9 +1822,10 @@ If the input line ends in a backslash and the \fB\-r\fP option was not used, the backslash and newline are stripped and more input is read. If no input is read, \fBread\fP exits with a non-zero status. .sp -A prompt, which is printed to standard error before any input is read, may be -specified by appending and question mark and the prompt to the -first parameter (\fIe.g.\fP, \fBread nfoo?'number of foos: '\fP). +The first parameter may have a question mark and a string appended to it, in +which case the string is used as a prompt (printed to standard error before +any input is read) if the input is a tty +(\fIe.g.\fP, \fBread nfoo?'number of foos: '\fP). .sp The \fB\-u\fP\fIn\fP and \fB\-p\fP options cause input to be read from file descriptor \fIn\fP or the current co-process (see Co-Processes above diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index 6c11aa00c11..3b8a3dd63ee 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.4 1996/10/13 21:32:19 downsj Exp $ */ +/* $OpenBSD: lex.c,v 1.5 1996/11/21 07:59:32 downsj Exp $ */ /* * lexical analysis and source input @@ -871,6 +871,7 @@ getsc__() s = source; /* avoid reading eof twice */ s->str = NULL; + break; } } continue; diff --git a/bin/ksh/main.c b/bin/ksh/main.c index ad3cce92323..e8425e1fab8 100644 --- a/bin/ksh/main.c +++ b/bin/ksh/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.3 1996/10/01 02:05:45 downsj Exp $ */ +/* $OpenBSD: main.c,v 1.4 1996/11/21 07:59:33 downsj Exp $ */ /* * startup, main loop, enviroments and error handling @@ -16,17 +16,17 @@ extern char **environ; * global data */ -static void reclaim ARGS((void)); -static void remove_temps ARGS((struct temp *tp)); -static int is_restricted ARGS((char *name)); +static void reclaim ARGS((void)); +static void remove_temps ARGS((struct temp *tp)); +static int is_restricted ARGS((char *name)); /* * shell initialization */ -static const char initifs [] = "IFS= \t\n"; /* must be R/W */ +static const char initifs [] = "IFS= \t\n"; /* must be R/W */ -static const char initsubs [] = +static const char initsubs [] = "${PS2=> } ${PS3=#? } ${PS4=+ }"; static const char version_param[] = @@ -37,7 +37,7 @@ static const char version_param[] = #endif /* KSH */ ; -static const char *const initcoms [] = { +static const char *const initcoms [] = { "typeset", "-x", "SHELL", "PATH", "HOME", NULL, "typeset", "-r", version_param, NULL, "typeset", "-ri", "PPID", NULL, @@ -120,11 +120,9 @@ main(argc, argv) ainit(&aperm); /* initialize permanent Area */ /* set up base enviroment */ + memset(&env, 0, sizeof(env)); env.type = E_NONE; ainit(&env.area); - env.savefd = NULL; - env.oenv = NULL; - env.loc = (struct block *) 0; e = &env; newblock(); /* set up global l->vars and l->funs */ @@ -729,6 +727,17 @@ cleanup_parents_env() e->oenv = (struct env *) 0; } +/* Called just before an execve cleanup stuff temporary files */ +void +cleanup_proc_env() +{ + struct env *ep; + + for (ep = e; ep; ep = ep->oenv) + remove_temps(ep->temps); + remove_temps(func_heredocs); +} + /* remove temp files and free ATEMP Area */ static void reclaim() @@ -743,25 +752,43 @@ remove_temps(tp) struct temp *tp; { #ifdef OS2 - static char tmpfile[30]; - int status; - - if (strlen (tmpfile) > 0 ) { - unlink(tmpfile); - *tmpfile=0; - } + static struct temp *delayed_remove; + struct temp *t, **tprev; + + if (delayed_remove) { + for (tprev = &delayed_remove, t = delayed_remove; t; t = *tprev) + /* No need to check t->pid here... */ + if (unlink(t->name) >= 0 || errno == ENOENT) { + *tprev = t->next; + afree(t, APERM); + } else + tprev = &t->next; + } #endif /* OS2 */ for (; tp != NULL; tp = tp->next) - if (tp->pid == procpid) + if (tp->pid == procpid) { #ifdef OS2 - { status=unlink(tp->name); - if (status < 0) - strcpy(tmpfile, tp->name); - } + /* OS/2 (and dos) do not allow files that are currently + * open to be removed, so we cache it away for future + * removal. + * XXX should only do this if errno + * is Efile-still-open-can't-remove + * (but I don't know what that is...) + */ + if (unlink(tp->name) < 0 && errno != ENOENT) { + t = (struct temp *) alloc( + sizeof(struct temp) + strlen(tp->name) + 1, + APERM); + memset(t, 0, sizeof(struct temp)); + strcpy(t->name, tp->name); + t->next = delayed_remove; + delayed_remove = t; + } #else /* OS2 */ unlink(tp->name); #endif /* OS2 */ + } } /* Returns true if name refers to a restricted shell */ diff --git a/bin/ksh/proto.h b/bin/ksh/proto.h index a290e18a205..608b451f593 100644 --- a/bin/ksh/proto.h +++ b/bin/ksh/proto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proto.h,v 1.2 1996/08/19 20:08:57 downsj Exp $ */ +/* $OpenBSD: proto.h,v 1.3 1996/11/21 07:59:34 downsj Exp $ */ /* * prototypes for PD-KSH @@ -165,6 +165,7 @@ void unwind ARGS((int i)) GCC_FUNC_ATTR(noreturn); void newenv ARGS((int type)); void quitenv ARGS((void)); void cleanup_parents_env ARGS((void)); +void cleanup_proc_env ARGS((void)); void aerror ARGS((Area *ap, const char *msg)) GCC_FUNC_ATTR(noreturn); /* misc.c */ diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c index 2d883c4eda8..53b85a20b74 100644 --- a/bin/ksh/syn.c +++ b/bin/ksh/syn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syn.c,v 1.4 1996/10/13 21:32:20 downsj Exp $ */ +/* $OpenBSD: syn.c,v 1.5 1996/11/21 07:59:35 downsj Exp $ */ /* * shell parser (C version) @@ -123,6 +123,9 @@ c_list() t = andor(); if (t != NULL) { + /* Token has always been read/rejected at this point, so + * we don't worray about what flags to pass token() + */ while ((c = token(0)) == ';' || c == '&' || c == COPROC || (c == '\n' && (multiline.on || inalias(source)))) { @@ -208,7 +211,10 @@ get_command(cf) XPinit(args, 16); XPinit(vars, 16); - if (multiline.on) + /* Don't want to pass CONTIN if reading interactively as just hitting + * return would print PS2 instead of PS1. + */ + if (multiline.on || inalias(source)) cf = CONTIN; syniocf = KEYWORD|ALIAS; switch (c = token(cf|KEYWORD|ALIAS|VARASN)) { diff --git a/bin/ksh/table.h b/bin/ksh/table.h index 753339c33bc..75215719c22 100644 --- a/bin/ksh/table.h +++ b/bin/ksh/table.h @@ -1,4 +1,4 @@ -/* $OpenBSD: table.h,v 1.2 1996/08/19 20:09:00 downsj Exp $ */ +/* $OpenBSD: table.h,v 1.3 1996/11/21 07:59:35 downsj Exp $ */ /* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */ @@ -66,6 +66,11 @@ struct tbl { /* table item */ #define FKSH BIT(11) /* function defined with function x (vs x()) */ #define SPEC_BI BIT(12) /* a POSIX special builtin */ #define REG_BI BIT(13) /* a POSIX regular builtin */ +/* Attributes that can be set by the user (used to decide if an unset param + * should be repoted by set/typeset). Does not include ARRAY or LOCAL. + */ +#define USERATTRIB (EXPORT|INTEGER|RDONLY|LJUST|RJUST|ZEROFIL\ + |LCASEV|UCASEV_AL|INT_U|INT_L) /* command types */ #define CNONE 0 /* undefined */ diff --git a/bin/ksh/tests/history.t b/bin/ksh/tests/history.t index 707327ed37c..078aeb60969 100644 --- a/bin/ksh/tests/history.t +++ b/bin/ksh/tests/history.t @@ -73,7 +73,7 @@ expected-stderr-pattern: name: history-e-minus-4 description: - "fc -e | more" works + Check if "fc -e -" command output goes to stdout. arguments: !-i! env-setup: !ENV=./Env!HISTFILE=hist.file! perl-setup: system("echo PS1=X > Env"); diff --git a/bin/ksh/tests/regress.t b/bin/ksh/tests/regress.t index 218fc55249a..675ae53497a 100644 --- a/bin/ksh/tests/regress.t +++ b/bin/ksh/tests/regress.t @@ -34,10 +34,14 @@ stdin: mkdir Y cat > Y/xxxscript << EOF #!/bin/sh + # Need to restore path so echo can be found (some shells don't have + # it as a built-in) + PATH=\$OLDPATH echo hi exit 0 EOF chmod a+rx Y/xxxscript + export OLDPATH="$PATH" PATH=$PWD/Y xxxscript exit $? expected-stdout: @@ -203,7 +207,7 @@ description: NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading commands from /etc/termcap..) -time-limit: 4 +time-limit: 10 stdin: echo A line of text that will be duplicated quite a number of times.> t1 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2 @@ -645,7 +649,7 @@ description: Can subshells be prefixed by redirections (historical shells allow this) stdin: - < /dev/null (cat -n) + < /dev/null (sed 's/^/X/') --- name: regression-44 @@ -682,3 +686,85 @@ expected-stdout: <[abc]> <a[bc> --- + +name: regression-46 +description: + Check that alias expansion works in command substitutions and + at the end of file. +stdin: + alias x='echo hi' + FOO="`x` " + echo "[$FOO]" + x +expected-stdout: + [hi ] + hi +--- + +name: regression-47 +description: + Check that aliases are fully read. +stdin: + alias x='echo hi; + echo there' + x + echo done +expected-stdout: + hi + there + done +--- + +name: regression-48 +description: + Check that (here doc) temp files are not left behind after an exec. +stdin: + mkdir foo || exit 1 + TMPDIR=$PWD/foo $0 <<- 'EOF' + x() { + sed 's/^/X /' << E_O_F + hi + there + folks + E_O_F + echo "done ($?)" + } + exec /bin/echo subtest-1 hi + EOF + echo subtest-1 foo/* + TMPDIR=$PWD/foo $0 <<- 'EOF' + sed 's/^/X /' << E_O_F; exec /bin/echo subtest-2 hi + a + few + lines + E_O_F + EOF + echo subtest-2 foo/* +expected-stdout: + subtest-1 hi + subtest-1 foo/* + X a + X few + X lines + subtest-2 hi + subtest-2 foo/* +--- + +name: regression-49 +description: + Check that unset params with attributes are reported by set, those + sans attributes are not. +stdin: + unset FOO BAR + echo X$FOO + export BAR + typeset -i BLAH + set | grep FOO + set | grep BAR + set | grep BLAH +expected-stdout: + X + BAR + BLAH +--- + diff --git a/bin/ksh/tests/th.sh b/bin/ksh/tests/th.sh index f26b8699e94..3ca78e8c955 100644 --- a/bin/ksh/tests/th.sh +++ b/bin/ksh/tests/th.sh @@ -5,6 +5,7 @@ # # Avoid common problems with ENV (though perl shouldn't let it through) +# (can you believe some shells don't have an unset???) unset ENV x=x diff --git a/bin/ksh/tests/version.t b/bin/ksh/tests/version.t index 51abf75f296..23d834015fa 100644 --- a/bin/ksh/tests/version.t +++ b/bin/ksh/tests/version.t @@ -4,5 +4,5 @@ description: stdin: echo $KSH_VERSION expected-stdout: - @(#)PD KSH v5.2.11 96/10/08 + @(#)PD KSH v5.2.12 96/10/29 --- diff --git a/bin/ksh/tty.h b/bin/ksh/tty.h index 3982fa9752d..a6cd2dae1e9 100644 --- a/bin/ksh/tty.h +++ b/bin/ksh/tty.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.h,v 1.1 1996/08/14 06:19:12 downsj Exp $ */ +/* $OpenBSD: tty.h,v 1.2 1996/11/21 07:59:36 downsj Exp $ */ /* tty.h -- centralized definitions for a variety of terminal interfaces @@ -20,12 +20,34 @@ # define EXTERN_DEFINED #endif +/* Don't know of a system on which including sys/ioctl.h with termios.h + * causes problems. If there is one, these lines need to be deleted and + * aclocal.m4 needs to have stuff un-commented. + */ +#ifdef SYS_IOCTL_WITH_TERMIOS +# define SYS_IOCTL_WITH_TERMIOS +#endif /* SYS_IOCTL_WITH_TERMIOS */ +#ifdef SYS_IOCTL_WITH_TERMIO +# define SYS_IOCTL_WITH_TERMIO +#endif /* SYS_IOCTL_WITH_TERMIO */ + #ifdef HAVE_TERMIOS_H # include <termios.h> +# ifdef SYS_IOCTL_WITH_TERMIOS +# if !(defined(sun) && !defined(__svr4__)) /* too many warnings on sunos */ + /* Need to include sys/ioctl.h on some systems to get the TIOCGWINSZ + * stuff (eg, digital unix). + */ +# include <sys/ioctl.h> +# endif /* !(sun && !__svr4__) */ +# endif /* SYS_IOCTL_WITH_TERMIOS */ typedef struct termios TTY_state; #else # ifdef HAVE_TERMIO_H # include <termio.h> +# ifdef SYS_IOCTL_WITH_TERMIO +# include <sys/ioctl.h> /* see comment above in termios stuff */ +# endif /* SYS_IOCTL_WITH_TERMIO */ # if _BSD_SYSV /* BRL UNIX System V emulation */ # ifndef NTTYDISC # define TIOCGETD _IOR( 't', 0, int ) diff --git a/bin/ksh/version.c b/bin/ksh/version.c index c676ba774c6..54394213105 100644 --- a/bin/ksh/version.c +++ b/bin/ksh/version.c @@ -1,4 +1,4 @@ -/* $OpenBSD: version.c,v 1.4 1996/10/13 21:32:21 downsj Exp $ */ +/* $OpenBSD: version.c,v 1.5 1996/11/21 07:59:37 downsj Exp $ */ /* * value of $KSH_VERSION (or $SH_VERSION) @@ -7,4 +7,4 @@ #include "sh.h" const char ksh_version [] = - "@(#)PD KSH v5.2.11 96/10/08"; + "@(#)PD KSH v5.2.12 96/10/29"; diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c index 4fc7b75c511..4410276a68e 100644 --- a/bin/ksh/vi.c +++ b/bin/ksh/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.2 1996/08/19 20:09:04 downsj Exp $ */ +/* $OpenBSD: vi.c,v 1.3 1996/11/21 07:59:37 downsj Exp $ */ /* * vi command editing @@ -1137,7 +1137,8 @@ vi_cmd(argcnt, cmd) case Ctrl('i'): /* Nonstandard vi/ksh */ if (!Flag(FVITABCOMPLETE)) return -1; - /* FALLTHROUGH */ + complete_word(1, argcnt); + break; case Ctrl('['): /* some annoying at&t ksh's */ if (!Flag(FVIESCCOMPLETE)) @@ -1843,11 +1844,11 @@ display(wb1, wb2, leftside) if (ch < ' ' || ch == 0x7f) { *twb1++ = '^'; if (++col < winwidth) { - *twb1++ = es->cbuf[cur] ^ '@'; + *twb1++ = ch ^ '@'; col++; } } else { - *twb1++ = es->cbuf[cur]; + *twb1++ = ch; col++; } } |