diff options
Diffstat (limited to 'bin')
55 files changed, 794 insertions, 435 deletions
diff --git a/bin/ksh/BUG-REPORTS b/bin/ksh/BUG-REPORTS index f889fe108a8..d87a0c7276a 100644 --- a/bin/ksh/BUG-REPORTS +++ b/bin/ksh/BUG-REPORTS @@ -1,4 +1,4 @@ -$OpenBSD: BUG-REPORTS,v 1.2 1996/08/19 20:08:39 downsj Exp $ +$OpenBSD: BUG-REPORTS,v 1.3 1996/10/01 02:05:23 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 *, @@ -35,12 +35,6 @@ problems believed to be fixed marked by x. system to hang after executing two commands. [see Mail.3:96,5:42] -* pdksh 5.1.3, NeXT machines (reported by Jason Baugher): job control doesn't - work on NeXT machines (both m68k and x86 based) in rlogin sessions. - (caused by open("/dev/tty") failing - rlogin on NeXT doesn't set up - controlling tty properly). - [see Mail.7:29] - * pdksh 5.1.3, - (reported by Brad Warkentin & others): if the last command of a pipeline is a shell builtin, it is not executed in the parent shell, so "echo a b | read foo bar" does not set foo and bar in the parent @@ -64,11 +58,8 @@ problems believed to be fixed marked by x. [see Mail.8:43] * enhancements that haven't been merged yet - - Mail.6:36-39,78,84 recursive function diffs - -* pdksh 5.2.3, - (reported by Mike Jetzer): in vi, <ESC>= on word with ~ - but no /, beeps (or prints final path comonent?). - [see Mail.9:66] + - Mail.6:36-39,78,84 recursive function diffs (add hard limit on + depeth of recursion) * pdksh 5.2.3, - (reported by David Gast(? gast@twinsun.com)): history (fc, et al) don't work in shell scripts. @@ -83,11 +74,6 @@ problems believed to be fixed marked by x. multiline commands - should go to start of command. [see Mail.XXX:XXX] -* pdksh 5.2.5, - (reported by Adrian Marsh): configuration on Linux FT fails. - Caused by configure script using -g flag - gcc passes -lg to ld, ld fails - to find -lg (autoconf or Linux FT bug). - [see Mail.XXX:XXX] - * pdksh 5.2.7, - (reported by Adrian Marsh): typeset -L20u xxx is ok is ksh88 but not in pdksh. [see Mail.XXX:XXX] @@ -96,10 +82,7 @@ problems believed to be fixed marked by x. select and read operations. [see Mail.XXX:XXX] -* pdksh 5.2.7, - (reported by Gabor Zahemszky): exec 3<&p doesn't close - shells copy of the coprocess file desc. - [see Mail.XXX:XXX] - +* pdksh 5.2.8, - : extended pattern globing doesn't handle nested parens (). --------------------- put fixed problems below this line --------------------- @@ -1026,3 +1009,62 @@ x pdksh 5.2.7, - (reported by Gabor Zahemszky): unsetting a function while [see Mail.XXX:XXX] [fixed in 5.2.8: table.c(texpand) - dont free if FINUSE is set] +* pdksh 5.2.7, - (reported by Gabor Zahemszky): exec 3<&p doesn't close + shells copy of the coprocess file desc. + [see Mail.XXX:XXX] + [fixed in 5.2.8: coprocess stuff made to act like ksh93 co-processes] + +x pdksh 5.2.8, - (reported with fix by Lars Hecking): doesn't compile as + sh - c_ksh.c and jobs.c boom out. + [see Mail.XXX:XXX] + [fixed in 5.2.9: added ifdef KSH to appropriate places] + +x pdksh 5.2.8, - (reported by Paolo Zeppegno): assignments containing brackets + are treated as commands. + [see Mail.XXX:XXX] + [fixed in 5.2.9: fixed bug in vars.c(skip_wdvarname).] + +x pdksh 5.2.5, - (reported by Adrian Marsh): configuration on Linux FT fails. + Caused by configure script using -g flag - gcc passes -lg to ld, ld fails + to find -lg (autoconf or Linux FT bug). + [see Mail.XXX:XXX] + [fixed in 5.2.9: changed autoconf's -g test to do linking as well.] + +x pdksh 5.2.8, Solaris 2.5.1 (reported by Stefan Dalibor): 2 tests + (xxx-exec-environment-1 and 2) fail because printenv isn't found. + [see Mail.XXX:XXX] + [fixed in 5.2.9: changed test to use env instead] + +x pdksh 5.2.8, - (reported by Stefan Dalibor): shell assumes 80 columns when + it starts up if COLUMNS is set correctly in the environ. + [see Mail.XXX:XXX] + [fixed in 5.2.9: fixed so window size is checked at startup] + +x pdksh 5.2.8, NeXT machines (reported by Kai Wong): clock_t, which lives + in sys/time.h, isn't found by configure (causes warning messages). + [fixed in 5.2.9: configure now checks in sys/time.h] + +x pdksh 5.2.3, - (reported by Mike Jetzer): in vi, <ESC>= on word with ~ + but no /, beeps (or prints final path comonent?). + [see Mail.9:66] + [fixed in 5.2.9: fixed edit.c(add_glob) so no * is appended to ~username] + +x pdksh 5.1.3, NeXT machines (reported by Jason Baugher): job control doesn't + work on NeXT machines (both m68k and x86 based) in rlogin sessions. + (caused by open("/dev/tty") failing - rlogin on NeXT doesn't set up + controlling tty properly). + [see Mail.7:29] + [fixed in 5.2.9: added hack to main to get a controlling tty] + +x pdksh 5.2.8, NeXT 3.2 (reported by Andrew S Townley): the output of the + siglist.sh script fills the disk. Also, the signal list generated (by the + fixed script) is mostly empty. + [see Mail.XXX] + [fixed in 5.2.9: fixed siglist.sh script to avoid infinite loops. Added + comment to README warning of problem with NeXT's native cc -E] + +x pdksh 5.2.9, - (reported by Loris Talpo): long prompts are messed up in + vi mode. + [see Mail.XXX] + [fixed in 5.2.9: lex.c(pprompt) was broken] + diff --git a/bin/ksh/CONTRIBUTORS b/bin/ksh/CONTRIBUTORS index 34a1e6e6caa..edf32c0db35 100644 --- a/bin/ksh/CONTRIBUTORS +++ b/bin/ksh/CONTRIBUTORS @@ -1,4 +1,4 @@ -$OpenBSD: CONTRIBUTORS,v 1.2 1996/08/19 20:08:40 downsj Exp $ +$OpenBSD: CONTRIBUTORS,v 1.3 1996/10/01 02:05:25 downsj Exp $ This is a partial history of this shell gleened from old change logs and readmes (most of which are still in the misc directory) and the source @@ -95,3 +95,9 @@ Other contributors: * Arnon Kanfi (<arnon@gilly.datatools.com>): fix for prompt. * Marc Olzheim (<marcolz@stack.urc.tue.nl>): patches to ifdef KSH the mail check code and aliases. + * Lars Hecking (<lhecking@nmrc.ucc.ie>): fixes so shell compiles as sh + again. + * Bill Kish (<kish@browncow.com>): added prompt delimiter hack for + hidden characters (eg, escape codes). + * Andrew S. Townley (<atownley@informix.com>): fixes for NeXT machines: + get a controlling if one needed, use correct profile. diff --git a/bin/ksh/ChangeLog b/bin/ksh/ChangeLog index a5bab4fa1f0..e1c250f8e24 100644 --- a/bin/ksh/ChangeLog +++ b/bin/ksh/ChangeLog @@ -1,4 +1,77 @@ -$OpenBSD: ChangeLog,v 1.2 1996/08/19 20:08:41 downsj Exp $ +$OpenBSD: ChangeLog,v 1.3 1996/10/01 02:05:26 downsj Exp $ + +Mon Sep 30 17:14:41 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * made pdksh-5.2.9 distribution + +Mon Sep 30 12:52:21 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * lex.c(pprompt): fixed usage of ntruncate. + +Thu Sep 19 17:43:33 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * sh.h(KSH_SYSTEM_PROFILE): new define. + * main.c(main): use KSH_SYSTEM_PROFILE. + + * aclocal.m4(KSH_OS_TYPE): added case for NEXT. + +Thu Sep 19 15:39:54 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * tty.c(tty_init): added hack for NeXT's rlogin's missing controlling + tty. + +Mon Sep 16 11:18:10 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * edit.c(add_glob): don't append a * to a ~username. + + * edit.c(x_init): set got_sigwinch before calling check_sigwinch(). + +Wed Sep 11 14:38:38 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * c_ksh.c(c_let): ifdef'd KSH. + * lex.h(SDPAREN),lex.c: ifdef'd KSH all uses of SDPAREN. + * lex.h(MDPAREN),syn.c: ifdef'd KSH all uses of MDPAREN. + +Mon Sep 9 16:18:03 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4(AC_PROG_CC): replaced autoconf's version with + modified version. + + * configure.in(clock_t): check in sys/time.h as well. + * ksh_times.h: include ksh_time.h. + * ksh_time.h,ksh_times.h: added ifndef KSH_TIME_H/KSH_TIMES_H. + +Fri Sep 6 13:20:24 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * edit.c(promptlen): X\r hack for delimiting hidden characters + in prompt. + (Based on fix from Bill Kish) + +Tue Sep 3 11:03:26 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * Makefile.in: removed options.h from HDRS (also removed file). + +Thu Aug 29 10:04:01 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4(KSH_MEMMOVE): added return 0 to end of main(). + +Fri Aug 23 14:23:50 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4,ksh_stat.h: changed S_IFFIFO to S_IFIFO. + +Fri Aug 23 09:58:09 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * var.c(skip_wdvarname): don't check for array if first char + isn't [. + +Thu Aug 22 12:51:25 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * jobs.c: added ifdef KSH around Coproc_id/j->coproc_id usagae. + * c_ksh.c(c_read): added ifdef KSH around opipe. + +Tue Aug 20 09:41:32 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * configure.in: fixed quoting of sed LDSTATIC expression. Mon Aug 19 14:26:08 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) diff --git a/bin/ksh/IAFA-PACKAGE b/bin/ksh/IAFA-PACKAGE index 26a19b94d19..d93847222ca 100644 --- a/bin/ksh/IAFA-PACKAGE +++ b/bin/ksh/IAFA-PACKAGE @@ -1,7 +1,7 @@ -$OpenBSD: IAFA-PACKAGE,v 1.2 1996/08/19 20:08:42 downsj Exp $ +$OpenBSD: IAFA-PACKAGE,v 1.3 1996/10/01 02:05:27 downsj Exp $ Title: pdksh -Version: 5.2.8 +Version: 5.2.9 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 9c5f173d6ba..8efe211b889 100644 --- a/bin/ksh/NEWS +++ b/bin/ksh/NEWS @@ -1,4 +1,23 @@ -$OpenBSD: NEWS,v 1.2 1996/08/19 20:08:42 downsj Exp $ +$OpenBSD: NEWS,v 1.3 1996/10/01 02:05:28 downsj Exp $ + +Version 5.2.9 + +* bug fixes + * config: using LDSTATIC no longer generates config error. + * config: can compile as sh again (--enable-shell=sh). + * config: should compile on machines with broken "gcc -g" + * config: fixed test for broken S_IFIFO. + * config: fixed test for getwd() routine. + * config: better NeXT support (signal list generated correctly, clock_t + type detected, enable job contorl in rlogin sessions) + * parsing: assignments containing brackets ([]) not treated as commands. + * editing: terminal column width determined correctly on startup. + * vi: long prompts truncated (more or less) correctly. + * file completion: files of the form ~user (no /'s) expanded correctly. + +* at&t ksh method for delimiting hidden characters in prompt added (i.e., + start prompt with non-printing char and \r, use char to delimit esc codes). + Version 5.2.8 @@ -9,11 +28,11 @@ Version 5.2.8 * redirections before subshells handled correctly. * COLUMNS/LINES are no longer exported when they are automatically set. * mail checks and PS1/PS4 expansions removed if compiled as sh. - * subcommands in PS1 no longer genereate bogus warning messages. + * subcommands in PS1 no longer generate bogus warning messages. * environment variables not longer messed up on 16-bit machines. * unset: now returns non-zero if variable/function isn't set. * select: only prints menu first time, if REPLY is null or on blank line. - * check for `cannot execute' imporved, error message says why. + * check for `cannot execute' improved, error message says why. * typeset: now reports variables with attributes but now value. * vi/emacs file completion: does directory listing on zero length names. * arithmetic: non-numeric parameters expanded recursively. diff --git a/bin/ksh/NOTES b/bin/ksh/NOTES index 96a2af3aada..17f29108eda 100644 --- a/bin/ksh/NOTES +++ b/bin/ksh/NOTES @@ -1,4 +1,4 @@ -$OpenBSD: NOTES,v 1.2 1996/08/19 20:08:43 downsj Exp $ +$OpenBSD: NOTES,v 1.3 1996/10/01 02:05:29 downsj Exp $ General features of at&t ksh that are not (yet) in pdksh: - exported aliases. @@ -16,7 +16,7 @@ General features of at&t ksh that are not (yet) in pdksh: Known bugs (see also BUG-REPORTS and PROJECTS files): Variable parsing, Expansion: - some specials behave differently when unset (eg, IFS behaves like - " \t\n") others loose their special meaning. IFS/PATH taken care of, + " \t\n") others lose their special meaning. IFS/PATH taken care of, still need to sort out some others (eg, TMOUT). Parsing,Lexing: - line numbers in errors are wrong for nested construct. Need to @@ -25,8 +25,11 @@ Known bugs (see also BUG-REPORTS and PROJECTS files): - a $(..) expression nested inside double quotes inside another $(..) isn't parsed correctly (eg, $(echo "foo$(echo ")")") ) Commands,Execution: - - setting special parameters in front of a command - (eg, HISTFILE=/foo/bar echo hi) effects the parent shell... + - setting special parameters that have side effects when + changed/restored (ie, HISTFILE, OPTIND, RANDOM) in front + of a command (eg, HISTFILE=/foo/bar echo hi) effects the parent + shell. Note that setting other (not so special) parameters + does not effect the parent shell. - `echo hi | exec cat -n' causes at&t to exit, `exec echo hi | cat -n' does not. pdksh exits for neither. Don't think POSIX requires an exit, but not sure. @@ -59,6 +62,13 @@ Known differences between pdksh & at&t ksh (that may change) - in ksh93, `. name' calls a function (defined with function) with POSIX semantics (instead of ksh semantics). in pdksh, . does not call functions. + - test: "test -f foo bar blah" is the same as "test -f foo" (the extra + arguments, of which there must be at least 2, are ignored) - pdksh + generates an error message (unexpected operator/operand "bar") as it + should. Sometimes used to test file globs (e.g., if test -f *.o; ...). + - if the command 'sleep 5 && /bin/echo blah' is run interactively and + is the sleep is stopped (^Z), the echo is run immediately in pdksh. + In at&t ksh, the whole thing is stopped. Known differences between pdksh & at&t ksh (that are not likely to change) - at&t ksh seems to catch or ignore SIGALRM - pdksh dies upon receipt diff --git a/bin/ksh/PROJECTS b/bin/ksh/PROJECTS index 271dc3ccad9..917960ca4a0 100644 --- a/bin/ksh/PROJECTS +++ b/bin/ksh/PROJECTS @@ -1,4 +1,4 @@ -$OpenBSD: PROJECTS,v 1.2 1996/08/19 20:08:44 downsj Exp $ +$OpenBSD: PROJECTS,v 1.3 1996/10/01 02:05:30 downsj Exp $ Things to be done in pdksh (see also the NOTES file): @@ -110,7 +110,3 @@ Things to be done in pdksh (see also the NOTES file): * teach shf_vfprintf() about long long's (%lld); also make %p use long longs if appropriate. - - * add \[...\] parsing to prompt printing (don't count width of chars - inside the \[..\] - used to keep escape sequences in prompts from - messing up command-line-editor's idea of where the cursor is) diff --git a/bin/ksh/README b/bin/ksh/README index 86575be9c34..032fadafd55 100644 --- a/bin/ksh/README +++ b/bin/ksh/README @@ -1,6 +1,6 @@ -$OpenBSD: README,v 1.2 1996/08/19 20:08:44 downsj Exp $ +$OpenBSD: README,v 1.3 1996/10/01 02:05:31 downsj Exp $ -Last updated August '96 for pdksh-5.2.8. +Last updated September '96 for pdksh-5.2.9. (check ftp://ftp.cs.mun.ca:/pub/pdksh/ or http://www.cs.mun.ca/~michael/pdksh/ for new versions/patches) @@ -57,6 +57,7 @@ Compiling/Installing: make check # optional make install # will install /usr/local/bin/ksh # and /usr/local/man/man1/ksh.1 + [add path-to-installed-pdksh to /etc/shells] The more detailed description: * run "configure --help | your-favorite-pager" and look at the @@ -106,19 +107,43 @@ Compiling/Installing: * On Linux (red hat distribution), check that /dev/tty has mode 0666 (not mode 0644). If it has the wrong permissions, ksh will print warnings about not being able to do job control. + * on NeXT machines (3.2, probably other releases), the siglist.out file + won't be generated correctly if you try to use the system's compiler + (it has a broken cc -E and strange header files). There are two + ways to make it work: + 1) if you have gcc, use it (for everything). Alternatively, + force configure to use it for CPP, i.e., use + CPP="gcc -E" configure ... + 2) Force configure to use some extra CPPFLAGS, using + CPPFLAGS="XXX" configure ... + where XXX is obtained from running "cc -v YYY.c" on some + C file. Look at the options passed to cpp (there are lots + of them...) and replace the XXX above with them. + Make sure you do a "make distclean" (or "rm config.cache") if + you re-run configure with a difference CPP or CPPFLAGS. + Also note that if you are building multiple arch binaries, you + will have to specify both CC and CPP. * run make: everything should compile and link without problems. - * run make check: this fires up a perl script that checks for some - known and some fixed bugs. The script prints pass/fail for tests - it expected to pass/fail, and PASS/FAIL for tests it expected to - fail/pass. + * run make check: this fires up a perl script that checks for some known + and some fixed bugs. The script prints pass/fail for tests it expected + 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 + instead. * run make install: this installs ksh (in /usr/local/bin/ksh by default, or where ever you told configure to put things). + * add path-to-installed-pdksh to /etc/shells if it's not already there. + This is only needed if you intend to use pdksh as a login shell (things + like ftp won't allow users to connect in if their shell isn't in this + file). The following is a list of machines that pdksh is reported to work on: - -/PC Linux 1.x + -/PC Linux 1.x,2.x -/PC NetBSD 0.9a -/PC BSDI 1.1 -/PC FreeBSD 2.0, 2.1 + -/PC OpenBSD -/PC Interactive/Sunsoft 3.0.1 and 4.1 (note that problems have been reported with isc3.2 - see the BUG-REPORTS file) -/PC OS/2 @@ -126,12 +151,12 @@ The following is a list of machines that pdksh is reported to work on: Dec/alpha OSF/1 v2.x, v3.x Dec/alpha NetBSD 1.1B Dec/pmax Ultrix 4.2 - Dec/vax Ultrix 2.2 - Dec/vax 4.3BSD+NFS (MtXinu) + Dec/vax Ultrix 2.2 (not tested recently :-)) + Dec/vax 4.3BSD+NFS (MtXinu) (not tested recently :-)) HP/pa HP-UX 9.01 IBM/RS/6000 AIX 3.2.5 MIPS/m120 RISC/os 5.0 (bsd43 environ) - NeXT NeXTStep 3.2(?) + NeXT NeXTStep 3.2 Sun/sun4 SunOS 4.1.3, 4.1.4 Sun/sun4 Solaris 2.x Sun/sun386i SunOS 4.0.2 @@ -155,9 +180,9 @@ If you are reporting a bug (with or without a fix), please include * and a description of how to repeat the bug (a small shell script that demonstrates the bug is best). as well as the following, if relevant (if you aren't sure, include them) - * what options you are using (both options.h options and set -o options) + * what options you are using (both configure options and set -o options) * the output of configure, with the verbose flag - (eg, ./configure --verbose) + (eg, make distclean; ./configure --verbose) * the contents of config.log (this is created by the configure script) * if you are using gcc (the GNU C compiler), which version it is. diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c index 30832ecb4d3..a08ec31ae1c 100644 --- a/bin/ksh/c_ksh.c +++ b/bin/ksh/c_ksh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ksh.c,v 1.3 1996/08/25 12:37:55 downsj Exp $ */ +/* $OpenBSD: c_ksh.c,v 1.4 1996/10/01 02:05:32 downsj Exp $ */ /* * built-in Korn commands: c_* @@ -394,13 +394,17 @@ c_print(wp) for (s = Xstring(xs, xp); len > 0; ) { n = write(fd, s, len); if (n < 0) { +#ifdef KSH if (flags & PO_COPROC) restore_pipe(opipe); +#endif /* KSH */ if (errno == EINTR) { /* allow user to ^C out */ intrcheck(); +#ifdef KSH if (flags & PO_COPROC) opipe = block_pipe(); +#endif /* KSH */ continue; } #ifdef KSH @@ -985,6 +989,7 @@ c_unalias(wp) return rv; } +#ifdef KSH int c_let(wp) char **wp; @@ -1003,6 +1008,7 @@ c_let(wp) rv = val == 0; return rv; } +#endif /* KSH */ int c_jobs(wp) @@ -1370,7 +1376,9 @@ const struct builtin kshbuiltins [] = { {"+getopts", c_getopts}, {"+jobs", c_jobs}, {"+kill", c_kill}, +#ifdef KSH {"let", c_let}, +#endif /* KSH */ {"print", c_print}, {"pwd", c_pwd}, {"*=readonly", c_typeset}, diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c index 12e4fed77d5..c05109c859d 100644 --- a/bin/ksh/edit.c +++ b/bin/ksh/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.2 1996/08/19 20:08:47 downsj Exp $ */ +/* $OpenBSD: edit.c,v 1.3 1996/10/01 02:05:33 downsj Exp $ */ /* * Command line editing - common code @@ -52,6 +52,7 @@ x_init() if (setsig(&sigtraps[SIGWINCH], x_sigwinch, SS_RESTORE_ORIG|SS_SHTRAP)) sigtraps[SIGWINCH].flags |= TF_SHELL_USES; # endif /* SIGWINCH */ + got_sigwinch = 1; /* force initial check */ check_sigwinch(); #endif /* TIOCGWINSZ */ @@ -308,7 +309,6 @@ x_mode(onoff) * RETURN VALUE: * length */ - int promptlen(cp, spp) const char *cp; @@ -316,37 +316,35 @@ promptlen(cp, spp) { int count = 0; const char *sp = cp; + char delimiter = 0; + int indelimit = 0; + + /* Undocumented AT&T ksh feature: + * If the second char in the prompt string is \r then the first char + * is taken to be a non-printing delimiter and any chars between two + * instances of the delimiter are not considered to be part of the + * prompt length + */ + if (*cp && cp[1] == '\r') { + delimiter = *cp; + cp += 2; + } - while (*cp) { - if (*cp == '\n' || *cp == '\r') { + for (; *cp; cp++) { + if (indelimit && *cp != delimiter) + ; + else if (*cp == '\n' || *cp == '\r') { count = 0; - cp++; - sp = cp; + sp = cp + 1; } else if (*cp == '\t') { count = (count | 7) + 1; - cp++; } else if (*cp == '\b') { if (count > 0) count--; - cp++; - } -#if 1 + } else if (*cp == delimiter) + indelimit = !indelimit; else - cp++, count++; -#else - else if (*cp++ != '!') - count++; - else if (*cp == '!') { - cp++; count++; - } else { - register int i = source->line + 1; - - do - count++; - while ((i /= 10) > 0); - } -#endif /* 1 */ } if (spp) *spp = sp; @@ -822,6 +820,7 @@ add_glob(str, slen) { char *toglob; char *s; + bool_t saw_slash = FALSE; if (slen < 0) return (char *) 0; @@ -831,8 +830,9 @@ add_glob(str, slen) /* * If the pathname contains a wildcard (an unquoted '*', - * '?', or '[') or parameter expansion ('$'), then it is globbed - * based on that value (i.e., without the appended '*'). + * '?', or '[') or parameter expansion ('$'), or a ~username + * with no trailing slash, then it is globbed based on that + * value (i.e., without the appended '*'). */ for (s = toglob; *s; s++) { if (*s == '\\' && s[1]) @@ -840,8 +840,10 @@ add_glob(str, slen) else if (*s == '*' || *s == '[' || *s == '?' || *s == '$' || (s[1] == '(' /*)*/ && strchr("*+?@!", *s))) break; + else if (ISDIRSEP(*s)) + saw_slash = TRUE; } - if (!*s) { + if (!*s && (*toglob != '~' || saw_slash)) { toglob[slen] = '*'; toglob[slen + 1] = '\0'; } diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c index 32e2024206a..345b68df31a 100644 --- a/bin/ksh/exec.c +++ b/bin/ksh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.3 1996/08/25 12:38:00 downsj Exp $ */ +/* $OpenBSD: exec.c,v 1.4 1996/10/01 02:05:34 downsj Exp $ */ /* * execute command tree @@ -521,7 +521,7 @@ comexec(t, tp, ap, flags) fcflags |= FC_DEFPATH; } ap += builtin_opt.optind; - /* POSIX says special builtins loose their status + /* POSIX says special builtins lose their status * if accessed using command. */ keepasn_ok = 0; diff --git a/bin/ksh/ksh_stat.h b/bin/ksh/ksh_stat.h index 447b7b3f385..1abcc7cb1fc 100644 --- a/bin/ksh/ksh_stat.h +++ b/bin/ksh/ksh_stat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ksh_stat.h,v 1.2 1996/08/19 20:08:54 downsj Exp $ */ +/* $OpenBSD: ksh_stat.h,v 1.3 1996/10/01 02:05:39 downsj Exp $ */ /* Wrapper around the ugly sys/stat includes/ifdefs */ @@ -31,8 +31,8 @@ #if !defined(S_ISBLK) && defined(S_IFBLK) # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) #endif /* S_ISBLK */ -#if !defined(S_ISFIFO) && defined(S_IFFIFO) -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFFIFO) +#if !defined(S_ISFIFO) && defined(S_IFIFO) +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) #endif /* S_ISFIFO */ #if !defined(S_ISLNK) && defined(S_IFLNK) # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) diff --git a/bin/ksh/ksh_time.h b/bin/ksh/ksh_time.h index 21e98b9d147..ee8dc9b9128 100644 --- a/bin/ksh/ksh_time.h +++ b/bin/ksh/ksh_time.h @@ -1,4 +1,7 @@ -/* $OpenBSD: ksh_time.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */ +/* $OpenBSD: ksh_time.h,v 1.2 1996/10/01 02:05:40 downsj Exp $ */ + +#ifndef KSH_TIME_H +# define KSH_TIME_H /* Wrapper around the ugly time.h,sys/time.h includes/ifdefs */ @@ -20,3 +23,4 @@ extern time_t time ARGS((time_t *)); #ifndef CLK_TCK # define CLK_TCK 60 /* 60HZ */ #endif +#endif /* KSH_TIME_H */ diff --git a/bin/ksh/ksh_times.h b/bin/ksh/ksh_times.h index 45f1b793821..ec7b97eedf5 100644 --- a/bin/ksh/ksh_times.h +++ b/bin/ksh/ksh_times.h @@ -1,4 +1,10 @@ -/* $OpenBSD: ksh_times.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */ +/* $OpenBSD: ksh_times.h,v 1.2 1996/10/01 02:05:41 downsj Exp $ */ + +#ifndef KSH_TIMES_H +# define KSH_TIMES_H + +/* Needed for clock_t on some systems (ie, NeXT in non-posix mode) */ +#include "ksh_time.h" #include <sys/times.h> @@ -11,3 +17,4 @@ extern clock_t ksh_times ARGS((struct tms *)); #ifdef HAVE_TIMES extern clock_t times ARGS((struct tms *)); #endif /* HAVE_TIMES */ +#endif /* KSH_TIMES_H */ diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index 74ed0748fef..356d164e935 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.2 1996/08/19 20:08:55 downsj Exp $ */ +/* $OpenBSD: lex.c,v 1.3 1996/10/01 02:05:42 downsj Exp $ */ /* * lexical analysis and source input @@ -54,11 +54,14 @@ yylex(cf) if (cf&ONEWORD) istate = SWORD; +#ifdef KSH else if (cf&LETEXPR) { *wp++ = OQUOTE; /* enclose arguments in (double) quotes */ istate = SDPAREN; ndparen = 0; - } else { /* normal lexing */ + } +#endif /* KSH */ + else { /* normal lexing */ istate = (cf & HEREDELIM) ? SHEREDELIM : SBASE; while ((c = getsc()) == ' ' || c == '\t') ; @@ -411,6 +414,7 @@ yylex(cf) case SWORD: /* ONEWORD */ goto Subst; +#ifdef KSH case SDPAREN: /* LETEXPR: (( ... )) */ /*(*/ if (c == ')') { @@ -430,6 +434,7 @@ yylex(cf) */ ++ndparen; goto Sbase2; +#endif /* KSH */ case SHEREDELIM: /* <<,<<- delimiter */ /* XXX chuck this state (and the next) - use @@ -561,10 +566,12 @@ Done: return c; case '(': /*)*/ +#ifdef KSH if ((c2 = getsc()) == '(') /*)*/ c = MDPAREN; else ungetsc(c2); +#endif /* KSH */ return c; /*(*/ case ')': @@ -574,7 +581,11 @@ Done: *wp++ = EOS; /* terminate word */ yylval.cp = Xclose(ws, wp); - if (state == SWORD || state == SDPAREN) /* ONEWORD? */ + if (state == SWORD +#ifdef KSH + || state == SDPAREN +#endif /* KSH */ + ) /* ONEWORD? */ return LWORD; ungetsc(c); /* unget terminator */ @@ -1056,12 +1067,8 @@ pprompt(cp, ntruncate) shf_putc(c, shl_out); } #endif /* 0 */ - if (ntruncate) - shellf("%.*s", ntruncate, cp); - else { - shf_puts(cp, shl_out); - shf_flush(shl_out); - } + shf_puts(cp + ntruncate, shl_out); + shf_flush(shl_out); } /* Read the variable part of a ${...} expression (ie, up to but not including diff --git a/bin/ksh/lex.h b/bin/ksh/lex.h index f4517db927f..8d755ca031d 100644 --- a/bin/ksh/lex.h +++ b/bin/ksh/lex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */ +/* $OpenBSD: lex.h,v 1.2 1996/10/01 02:05:43 downsj Exp $ */ /* * Source input, lexer and parser @@ -51,7 +51,9 @@ struct source { */ #define SBASE 0 /* outside any lexical constructs */ #define SWORD 1 /* implicit quoting for substitute() */ +#ifdef KSH #define SDPAREN 2 /* inside (( )), implicit quoting */ +#endif /* KSH */ #define SSQUOTE 3 /* inside '' */ #define SDQUOTE 4 /* inside "" */ #define SBRACE 5 /* inside ${} */ @@ -93,7 +95,9 @@ typedef union { #define FUNCTION 274 #define TIME 275 #define REDIR 276 +#ifdef KSH #define MDPAREN 277 /* (( )) */ +#endif /* KSH */ #define BANG 278 /* ! */ #define DBRACKET 279 /* [[ .. ]] */ #define COPROC 280 /* |& */ diff --git a/bin/ksh/main.c b/bin/ksh/main.c index 74118b7f037..ad3cce92323 100644 --- a/bin/ksh/main.c +++ b/bin/ksh/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.2 1996/08/19 20:08:56 downsj Exp $ */ +/* $OpenBSD: main.c,v 1.3 1996/10/01 02:05:45 downsj Exp $ */ /* * startup, main loop, enviroments and error handling @@ -57,7 +57,9 @@ static const char *const initcoms [] = { #ifdef KSH "autoload=typeset -fu", "functions=typeset -f", +# ifdef HISTORY "history=fc -l", +# endif /* HISTORY */ "integer=typeset -i", "nohup=nohup ", "local=typeset", @@ -356,7 +358,7 @@ main(argc, argv) include(substitute("$HOME/profile.ksh", 0), 0, (char **) 0, 1); #else /* OS2 */ - include("/etc/profile", 0, (char **) 0, 1); + include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1); if (!Flag(FPRIVILEGED)) include(substitute("$HOME/.profile", 0), 0, (char **) 0, 1); diff --git a/bin/ksh/options.h b/bin/ksh/options.h deleted file mode 100644 index 0c83c904dbc..00000000000 --- a/bin/ksh/options.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $OpenBSD: options.h,v 1.2 1996/08/25 11:56:34 downsj Exp $ */ - -/* - * Options configuration file for the PD ksh - */ - -/* Define this to the path to use if the PATH environment variable is - * not set (ie, either never set or explicitly unset with the unset - * command). A value without . in it is safest. - * THIS DEFINE IS NOT USED if confstr() and _CS_PATH are available or - * if <paths.h> defines _PATH_DEFPATH. - */ -#ifdef OS2 -# define DEFAULT_PATH "c:/usr/bin;c:/os2;/os2" /* OS/2 only */ -#else /* OS2 */ -# define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb" /* Unix */ -#endif /* OS2 */ - - -/* Define KSH to get KSH features; otherwise, you get a fairly basic - * Bourne/POSIXish shell (undefining this results in EMACS, VI and - * COMPLEX_HISTORY being undefined as well, regardless of their setting - * here). - */ -/* #define KSH */ - -/* Define EMACS if you want emacs command line editing compiled in (enabled - * with "set -o emacs", or by setting the VISUAL or EDITOR variables to - * something ending in emacs). - */ -#define EMACS - -/* Define VI if you want vi command line editing compiled in (enabled with - * "set -o vi", or by setting the VISUAL or EDITOR variables to something - * ending in vi). - */ -#define VI - -/* Define JOBS if you want job control compiled in. This requires that your - * system support process groups and reliable signal handling routines (it - * will be automatically undefined if your system doesn't have them). - */ -#define JOBS - -/* Define BRACE_EXPAND if you want csh-like {} globbing compiled in and enabled - * (can be disabled with "set +o braceexpand"; also disabled by "set -o posix", - * but can be re-enabled with "set -o braceexpand"). - */ -#define BRACE_EXPAND - -/* Define COMPLEX_HISTORY if you want at&t ksh style history files (ie, file - * is updated after each command is read; concurrent ksh's read each other's - * commands, etc.). This option uses the mmap() and flock() functions - if - * these aren't available, the option is automatically undefined. If this - * option is not defined, a simplier history mechanism which reads/saves the - * history at startup/exit time, respectively, is used. COMPLEX_HISTORY is - * courtesy of Peter Collinson. - */ -#undef COMPLEX_HISTORY - -/* Define POSIXLY_CORRECT if you want POSIX behavior by default (otherwise, - * posix behavior is only turned on if the environment variable POSIXLY_CORRECT - * is present or by using "set -o posix"; it can be turned off with - * "set +o posix"). - * See the POSIX Mode section in the man page for details on what this option - * affects. - * NOTE: posix mode is not compatable with some bourne sh/at&t ksh scripts. - */ -#undef POSIXLY_CORRECT - -/* Define DEFAULT_ENV to be the name of the file (eg, "/etc/default.env") to - * include if the ENV environment variable is not set when the shell starts - * up. This can be useful when used with rsh(1) which creates a non-login - * shell (ie, profile not read) with an empty environment (ie, ENV not set). - * Setting ENV to null disables the inclusion of DEFAULT_ENV. - * NOTE: this is a non-standard feature (ie, at&t ksh has no default - * environment) - undefining this disables the use of a default ENV file. - */ -#undef DEFAULT_ENV - -/* Define SWTCH to handle SWITCH character, for use with shell layers (shl(1)). - * This has not been tested for some time. - */ -#undef SWTCH - -/* SILLY: The name says it all - compile game of life code into the emacs - * command line editing code. - */ -#undef SILLY diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h index f6578427d9c..b05a49d896e 100644 --- a/bin/ksh/sh.h +++ b/bin/ksh/sh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sh.h,v 1.2 1996/08/19 20:08:58 downsj Exp $ */ +/* $OpenBSD: sh.h,v 1.3 1996/10/01 02:05:47 downsj Exp $ */ /* * Public Domain Bourne/Korn shell @@ -682,6 +682,14 @@ EXTERN int x_cols I__(80); /* tty columns */ #define OBRACE '{' #define CBRACE '}' +/* Determine the location of the system (common) profile */ +#ifndef KSH_SYSTEM_PROFILE +# ifdef __NeXT +# define KSH_SYSTEM_PROFILE "/etc/profile.std" +# else /* __NeXT */ +# define KSH_SYSTEM_PROFILE "/etc/profile" +# endif /* __NeXT */ +#endif /* KSH_SYSTEM_PROFILE */ #include "shf.h" #include "table.h" diff --git a/bin/ksh/siglist.sh b/bin/ksh/siglist.sh index 420aaf6dd05..135e920d637 100644 --- a/bin/ksh/siglist.sh +++ b/bin/ksh/siglist.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: siglist.sh,v 1.1 1996/08/14 06:19:11 downsj Exp $ +# $OpenBSD: siglist.sh,v 1.2 1996/10/01 02:05:48 downsj Exp $ # # Script to generate a sorted, complete list of signals, suitable @@ -25,16 +25,18 @@ CPP="${1-cc -E}" #endif/') > $in $CPP $in > $out sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n | - sed 's/^[0-9]* //' | - awk 'BEGIN { last=0; nsigs=0; } - { - n = $2; - if (n > 0 && n != last) { - while (++last < n) { - printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last; - } - print; + sed 's/^[0-9]* //' | + awk 'BEGIN { last=0; nsigs=0; } + { + if ($2 ~ /^[0-9][0-9]*$/ && $3 == ",") { + n = $2; + if (n > 0 && n != last) { + while (++last < n) { + printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last; } - }' | - tr '`' '"' | grep -v '"DUMMY"' + print; + } + } + }' | + tr '`' '"' | grep -v '"DUMMY"' ecode=0 diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c index 8779c315841..c45d449d993 100644 --- a/bin/ksh/syn.c +++ b/bin/ksh/syn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syn.c,v 1.2 1996/08/19 20:08:59 downsj Exp $ */ +/* $OpenBSD: syn.c,v 1.3 1996/10/01 02:05:50 downsj Exp $ */ /* * shell parser (C version) @@ -284,6 +284,7 @@ get_command(cf) t = nested(TBRACE, '{', '}'); break; +#ifdef KSH case MDPAREN: { static const char let_cmd[] = { CHAR, 'l', CHAR, 'e', @@ -296,6 +297,7 @@ get_command(cf) XPput(args, yylval.cp); break; } +#endif /* KSH */ #ifdef KSH case DBRACKET: /* [[ .. ]] */ @@ -658,8 +660,8 @@ const struct tokeninfo { { "&&", LOGAND, FALSE }, { "||", LOGOR, FALSE }, { ";;", BREAK, FALSE }, - { "((", MDPAREN, FALSE }, #ifdef KSH + { "((", MDPAREN, FALSE }, { "|&", COPROC, FALSE }, #endif /* KSH */ /* and some special cases... */ diff --git a/bin/ksh/tests/regress.t b/bin/ksh/tests/regress.t index d78a02641de..218fc55249a 100644 --- a/bin/ksh/tests/regress.t +++ b/bin/ksh/tests/regress.t @@ -663,3 +663,22 @@ expected-stdout: OPTARG=x, OPTIND=3, optc=?. done --- + +name: regression-45 +description: + Parameter assignments with [] recognized correctly +stdin: + FOO=*[12] + BAR=abc[ + MORE=[abc] + JUNK=a[bc + echo "<$FOO>" + echo "<$BAR>" + echo "<$MORE>" + echo "<$JUNK>" +expected-stdout: + <*[12]> + <abc[> + <[abc]> + <a[bc> +--- diff --git a/bin/ksh/tests/unclass1.t b/bin/ksh/tests/unclass1.t index 2e3e88791bf..55d4e58976f 100644 --- a/bin/ksh/tests/unclass1.t +++ b/bin/ksh/tests/unclass1.t @@ -49,7 +49,7 @@ name: xxx-exec-environment-1 description: Check to see if exec sets it's environment correctly stdin: - FOO=bar exec printenv + FOO=bar exec env expected-stdout-pattern: /(^|.*\n)FOO=bar\n/ --- @@ -59,8 +59,8 @@ description: Check to make sure exec doesn't change environment if a program isn't exec-ed stdin: - printenv > bar1 - FOO=bar exec; printenv > bar2 + env > bar1 + FOO=bar exec; env > bar2 cmp -s bar1 bar2 --- diff --git a/bin/ksh/tests/version.t b/bin/ksh/tests/version.t index 0ec6fbac7b5..e1b8127fcbc 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.8 96/08/19 + @(#)PD KSH v5.2.9 96/09/30 --- diff --git a/bin/ksh/tty.c b/bin/ksh/tty.c index 5ee19fbba1d..00a94cd3ae6 100644 --- a/bin/ksh/tty.c +++ b/bin/ksh/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.1 1996/08/14 06:19:12 downsj Exp $ */ +/* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */ #include "sh.h" #include "ksh_stat.h" @@ -114,11 +114,30 @@ tty_init(init_ttystate) /* SCO can't job control on /dev/tty, so don't try... */ #if !defined(__SCO__) if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) { +#ifdef __NeXT + /* rlogin on NeXT boxes does not set up the controlling tty, + * so force it to be done here... + */ + { + extern char *ttyname ARGS((int)); + char *s = ttyname(isatty(2) ? 2 : 0); + int fd; + + if (s && (fd = open(s, O_RDWR, 0)) >= 0) { + close(fd); + tfd = open("/dev/tty", O_RDWR, 0); + } + } +#endif /* __NeXT */ + /* X11R5 xterm on mips doesn't set controlling tty properly - temporary hack */ # if !defined(__mips) || !(defined(_SYSTYPE_BSD43) || defined(__SYSTYPE_BSD43)) - tty_devtty = 0; - warningf(FALSE, "No controlling tty (open /dev/tty: %s)", - strerror(errno)); + if (tfd < 0) { + tty_devtty = 0; + warningf(FALSE, + "No controlling tty (open /dev/tty: %s)", + strerror(errno)); + } # endif /* __mips */ } #else /* !__SCO__ */ diff --git a/bin/ksh/var.c b/bin/ksh/var.c index b31b41d48a1..09ec84f0e3b 100644 --- a/bin/ksh/var.c +++ b/bin/ksh/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.2 1996/08/19 20:09:02 downsj Exp $ */ +/* $OpenBSD: var.c,v 1.3 1996/10/01 02:05:53 downsj Exp $ */ #include "sh.h" #include "ksh_time.h" @@ -757,7 +757,7 @@ skip_wdvarname(s, aok) do s += 2; while (s[0] == CHAR && letnum(s[1])); - if (aok) { + if (aok && s[0] == CHAR && s[1] == '[') { /* skip possible array de-reference */ const char *p = s; char c; @@ -1013,9 +1013,9 @@ unsetspec(vp) break; #endif /* KSH */ /* todo: generic action for specials (at&t says variables - * loose their special meaning when unset but global() checks + * lose their special meaning when unset but global() checks * the name of new vars to see if they are special) - * loose meaning: _, ERRNO, LINENO, MAILCHECK, + * lose meaning: _, ERRNO, LINENO, MAILCHECK, * OPTARG, OPTIND, RANDOM, SECONDS, TMOUT. * unknown: MAIL, MAILPATH, HISTSIZE, HISTFILE, * no effect: IFS, COLUMNS, PATH, TMPDIR, diff --git a/bin/ksh/version.c b/bin/ksh/version.c index edd71480d4c..d22e8f1ec29 100644 --- a/bin/ksh/version.c +++ b/bin/ksh/version.c @@ -1,4 +1,4 @@ -/* $OpenBSD: version.c,v 1.2 1996/08/19 20:09:03 downsj Exp $ */ +/* $OpenBSD: version.c,v 1.3 1996/10/01 02:05:54 downsj Exp $ */ /* * value of $KSH_VERSION (or $SH_VERSION) @@ -7,4 +7,4 @@ #include "sh.h" const char ksh_version [] = - "@(#)PD KSH v5.2.8 96/08/19"; + "@(#)PD KSH v5.2.9 96/09/30"; diff --git a/bin/pdksh/BUG-REPORTS b/bin/pdksh/BUG-REPORTS index f889fe108a8..d87a0c7276a 100644 --- a/bin/pdksh/BUG-REPORTS +++ b/bin/pdksh/BUG-REPORTS @@ -1,4 +1,4 @@ -$OpenBSD: BUG-REPORTS,v 1.2 1996/08/19 20:08:39 downsj Exp $ +$OpenBSD: BUG-REPORTS,v 1.3 1996/10/01 02:05:23 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 *, @@ -35,12 +35,6 @@ problems believed to be fixed marked by x. system to hang after executing two commands. [see Mail.3:96,5:42] -* pdksh 5.1.3, NeXT machines (reported by Jason Baugher): job control doesn't - work on NeXT machines (both m68k and x86 based) in rlogin sessions. - (caused by open("/dev/tty") failing - rlogin on NeXT doesn't set up - controlling tty properly). - [see Mail.7:29] - * pdksh 5.1.3, - (reported by Brad Warkentin & others): if the last command of a pipeline is a shell builtin, it is not executed in the parent shell, so "echo a b | read foo bar" does not set foo and bar in the parent @@ -64,11 +58,8 @@ problems believed to be fixed marked by x. [see Mail.8:43] * enhancements that haven't been merged yet - - Mail.6:36-39,78,84 recursive function diffs - -* pdksh 5.2.3, - (reported by Mike Jetzer): in vi, <ESC>= on word with ~ - but no /, beeps (or prints final path comonent?). - [see Mail.9:66] + - Mail.6:36-39,78,84 recursive function diffs (add hard limit on + depeth of recursion) * pdksh 5.2.3, - (reported by David Gast(? gast@twinsun.com)): history (fc, et al) don't work in shell scripts. @@ -83,11 +74,6 @@ problems believed to be fixed marked by x. multiline commands - should go to start of command. [see Mail.XXX:XXX] -* pdksh 5.2.5, - (reported by Adrian Marsh): configuration on Linux FT fails. - Caused by configure script using -g flag - gcc passes -lg to ld, ld fails - to find -lg (autoconf or Linux FT bug). - [see Mail.XXX:XXX] - * pdksh 5.2.7, - (reported by Adrian Marsh): typeset -L20u xxx is ok is ksh88 but not in pdksh. [see Mail.XXX:XXX] @@ -96,10 +82,7 @@ problems believed to be fixed marked by x. select and read operations. [see Mail.XXX:XXX] -* pdksh 5.2.7, - (reported by Gabor Zahemszky): exec 3<&p doesn't close - shells copy of the coprocess file desc. - [see Mail.XXX:XXX] - +* pdksh 5.2.8, - : extended pattern globing doesn't handle nested parens (). --------------------- put fixed problems below this line --------------------- @@ -1026,3 +1009,62 @@ x pdksh 5.2.7, - (reported by Gabor Zahemszky): unsetting a function while [see Mail.XXX:XXX] [fixed in 5.2.8: table.c(texpand) - dont free if FINUSE is set] +* pdksh 5.2.7, - (reported by Gabor Zahemszky): exec 3<&p doesn't close + shells copy of the coprocess file desc. + [see Mail.XXX:XXX] + [fixed in 5.2.8: coprocess stuff made to act like ksh93 co-processes] + +x pdksh 5.2.8, - (reported with fix by Lars Hecking): doesn't compile as + sh - c_ksh.c and jobs.c boom out. + [see Mail.XXX:XXX] + [fixed in 5.2.9: added ifdef KSH to appropriate places] + +x pdksh 5.2.8, - (reported by Paolo Zeppegno): assignments containing brackets + are treated as commands. + [see Mail.XXX:XXX] + [fixed in 5.2.9: fixed bug in vars.c(skip_wdvarname).] + +x pdksh 5.2.5, - (reported by Adrian Marsh): configuration on Linux FT fails. + Caused by configure script using -g flag - gcc passes -lg to ld, ld fails + to find -lg (autoconf or Linux FT bug). + [see Mail.XXX:XXX] + [fixed in 5.2.9: changed autoconf's -g test to do linking as well.] + +x pdksh 5.2.8, Solaris 2.5.1 (reported by Stefan Dalibor): 2 tests + (xxx-exec-environment-1 and 2) fail because printenv isn't found. + [see Mail.XXX:XXX] + [fixed in 5.2.9: changed test to use env instead] + +x pdksh 5.2.8, - (reported by Stefan Dalibor): shell assumes 80 columns when + it starts up if COLUMNS is set correctly in the environ. + [see Mail.XXX:XXX] + [fixed in 5.2.9: fixed so window size is checked at startup] + +x pdksh 5.2.8, NeXT machines (reported by Kai Wong): clock_t, which lives + in sys/time.h, isn't found by configure (causes warning messages). + [fixed in 5.2.9: configure now checks in sys/time.h] + +x pdksh 5.2.3, - (reported by Mike Jetzer): in vi, <ESC>= on word with ~ + but no /, beeps (or prints final path comonent?). + [see Mail.9:66] + [fixed in 5.2.9: fixed edit.c(add_glob) so no * is appended to ~username] + +x pdksh 5.1.3, NeXT machines (reported by Jason Baugher): job control doesn't + work on NeXT machines (both m68k and x86 based) in rlogin sessions. + (caused by open("/dev/tty") failing - rlogin on NeXT doesn't set up + controlling tty properly). + [see Mail.7:29] + [fixed in 5.2.9: added hack to main to get a controlling tty] + +x pdksh 5.2.8, NeXT 3.2 (reported by Andrew S Townley): the output of the + siglist.sh script fills the disk. Also, the signal list generated (by the + fixed script) is mostly empty. + [see Mail.XXX] + [fixed in 5.2.9: fixed siglist.sh script to avoid infinite loops. Added + comment to README warning of problem with NeXT's native cc -E] + +x pdksh 5.2.9, - (reported by Loris Talpo): long prompts are messed up in + vi mode. + [see Mail.XXX] + [fixed in 5.2.9: lex.c(pprompt) was broken] + diff --git a/bin/pdksh/CONTRIBUTORS b/bin/pdksh/CONTRIBUTORS index 34a1e6e6caa..edf32c0db35 100644 --- a/bin/pdksh/CONTRIBUTORS +++ b/bin/pdksh/CONTRIBUTORS @@ -1,4 +1,4 @@ -$OpenBSD: CONTRIBUTORS,v 1.2 1996/08/19 20:08:40 downsj Exp $ +$OpenBSD: CONTRIBUTORS,v 1.3 1996/10/01 02:05:25 downsj Exp $ This is a partial history of this shell gleened from old change logs and readmes (most of which are still in the misc directory) and the source @@ -95,3 +95,9 @@ Other contributors: * Arnon Kanfi (<arnon@gilly.datatools.com>): fix for prompt. * Marc Olzheim (<marcolz@stack.urc.tue.nl>): patches to ifdef KSH the mail check code and aliases. + * Lars Hecking (<lhecking@nmrc.ucc.ie>): fixes so shell compiles as sh + again. + * Bill Kish (<kish@browncow.com>): added prompt delimiter hack for + hidden characters (eg, escape codes). + * Andrew S. Townley (<atownley@informix.com>): fixes for NeXT machines: + get a controlling if one needed, use correct profile. diff --git a/bin/pdksh/ChangeLog b/bin/pdksh/ChangeLog index a5bab4fa1f0..e1c250f8e24 100644 --- a/bin/pdksh/ChangeLog +++ b/bin/pdksh/ChangeLog @@ -1,4 +1,77 @@ -$OpenBSD: ChangeLog,v 1.2 1996/08/19 20:08:41 downsj Exp $ +$OpenBSD: ChangeLog,v 1.3 1996/10/01 02:05:26 downsj Exp $ + +Mon Sep 30 17:14:41 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * made pdksh-5.2.9 distribution + +Mon Sep 30 12:52:21 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * lex.c(pprompt): fixed usage of ntruncate. + +Thu Sep 19 17:43:33 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * sh.h(KSH_SYSTEM_PROFILE): new define. + * main.c(main): use KSH_SYSTEM_PROFILE. + + * aclocal.m4(KSH_OS_TYPE): added case for NEXT. + +Thu Sep 19 15:39:54 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * tty.c(tty_init): added hack for NeXT's rlogin's missing controlling + tty. + +Mon Sep 16 11:18:10 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * edit.c(add_glob): don't append a * to a ~username. + + * edit.c(x_init): set got_sigwinch before calling check_sigwinch(). + +Wed Sep 11 14:38:38 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * c_ksh.c(c_let): ifdef'd KSH. + * lex.h(SDPAREN),lex.c: ifdef'd KSH all uses of SDPAREN. + * lex.h(MDPAREN),syn.c: ifdef'd KSH all uses of MDPAREN. + +Mon Sep 9 16:18:03 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4(AC_PROG_CC): replaced autoconf's version with + modified version. + + * configure.in(clock_t): check in sys/time.h as well. + * ksh_times.h: include ksh_time.h. + * ksh_time.h,ksh_times.h: added ifndef KSH_TIME_H/KSH_TIMES_H. + +Fri Sep 6 13:20:24 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * edit.c(promptlen): X\r hack for delimiting hidden characters + in prompt. + (Based on fix from Bill Kish) + +Tue Sep 3 11:03:26 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * Makefile.in: removed options.h from HDRS (also removed file). + +Thu Aug 29 10:04:01 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4(KSH_MEMMOVE): added return 0 to end of main(). + +Fri Aug 23 14:23:50 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * aclocal.m4,ksh_stat.h: changed S_IFFIFO to S_IFIFO. + +Fri Aug 23 09:58:09 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * var.c(skip_wdvarname): don't check for array if first char + isn't [. + +Thu Aug 22 12:51:25 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * jobs.c: added ifdef KSH around Coproc_id/j->coproc_id usagae. + * c_ksh.c(c_read): added ifdef KSH around opipe. + +Tue Aug 20 09:41:32 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) + + * configure.in: fixed quoting of sed LDSTATIC expression. Mon Aug 19 14:26:08 NDT 1996 Michael Rendell (michael@panda.cs.mun.ca) diff --git a/bin/pdksh/IAFA-PACKAGE b/bin/pdksh/IAFA-PACKAGE index 26a19b94d19..d93847222ca 100644 --- a/bin/pdksh/IAFA-PACKAGE +++ b/bin/pdksh/IAFA-PACKAGE @@ -1,7 +1,7 @@ -$OpenBSD: IAFA-PACKAGE,v 1.2 1996/08/19 20:08:42 downsj Exp $ +$OpenBSD: IAFA-PACKAGE,v 1.3 1996/10/01 02:05:27 downsj Exp $ Title: pdksh -Version: 5.2.8 +Version: 5.2.9 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/pdksh/NEWS b/bin/pdksh/NEWS index 9c5f173d6ba..8efe211b889 100644 --- a/bin/pdksh/NEWS +++ b/bin/pdksh/NEWS @@ -1,4 +1,23 @@ -$OpenBSD: NEWS,v 1.2 1996/08/19 20:08:42 downsj Exp $ +$OpenBSD: NEWS,v 1.3 1996/10/01 02:05:28 downsj Exp $ + +Version 5.2.9 + +* bug fixes + * config: using LDSTATIC no longer generates config error. + * config: can compile as sh again (--enable-shell=sh). + * config: should compile on machines with broken "gcc -g" + * config: fixed test for broken S_IFIFO. + * config: fixed test for getwd() routine. + * config: better NeXT support (signal list generated correctly, clock_t + type detected, enable job contorl in rlogin sessions) + * parsing: assignments containing brackets ([]) not treated as commands. + * editing: terminal column width determined correctly on startup. + * vi: long prompts truncated (more or less) correctly. + * file completion: files of the form ~user (no /'s) expanded correctly. + +* at&t ksh method for delimiting hidden characters in prompt added (i.e., + start prompt with non-printing char and \r, use char to delimit esc codes). + Version 5.2.8 @@ -9,11 +28,11 @@ Version 5.2.8 * redirections before subshells handled correctly. * COLUMNS/LINES are no longer exported when they are automatically set. * mail checks and PS1/PS4 expansions removed if compiled as sh. - * subcommands in PS1 no longer genereate bogus warning messages. + * subcommands in PS1 no longer generate bogus warning messages. * environment variables not longer messed up on 16-bit machines. * unset: now returns non-zero if variable/function isn't set. * select: only prints menu first time, if REPLY is null or on blank line. - * check for `cannot execute' imporved, error message says why. + * check for `cannot execute' improved, error message says why. * typeset: now reports variables with attributes but now value. * vi/emacs file completion: does directory listing on zero length names. * arithmetic: non-numeric parameters expanded recursively. diff --git a/bin/pdksh/NOTES b/bin/pdksh/NOTES index 96a2af3aada..17f29108eda 100644 --- a/bin/pdksh/NOTES +++ b/bin/pdksh/NOTES @@ -1,4 +1,4 @@ -$OpenBSD: NOTES,v 1.2 1996/08/19 20:08:43 downsj Exp $ +$OpenBSD: NOTES,v 1.3 1996/10/01 02:05:29 downsj Exp $ General features of at&t ksh that are not (yet) in pdksh: - exported aliases. @@ -16,7 +16,7 @@ General features of at&t ksh that are not (yet) in pdksh: Known bugs (see also BUG-REPORTS and PROJECTS files): Variable parsing, Expansion: - some specials behave differently when unset (eg, IFS behaves like - " \t\n") others loose their special meaning. IFS/PATH taken care of, + " \t\n") others lose their special meaning. IFS/PATH taken care of, still need to sort out some others (eg, TMOUT). Parsing,Lexing: - line numbers in errors are wrong for nested construct. Need to @@ -25,8 +25,11 @@ Known bugs (see also BUG-REPORTS and PROJECTS files): - a $(..) expression nested inside double quotes inside another $(..) isn't parsed correctly (eg, $(echo "foo$(echo ")")") ) Commands,Execution: - - setting special parameters in front of a command - (eg, HISTFILE=/foo/bar echo hi) effects the parent shell... + - setting special parameters that have side effects when + changed/restored (ie, HISTFILE, OPTIND, RANDOM) in front + of a command (eg, HISTFILE=/foo/bar echo hi) effects the parent + shell. Note that setting other (not so special) parameters + does not effect the parent shell. - `echo hi | exec cat -n' causes at&t to exit, `exec echo hi | cat -n' does not. pdksh exits for neither. Don't think POSIX requires an exit, but not sure. @@ -59,6 +62,13 @@ Known differences between pdksh & at&t ksh (that may change) - in ksh93, `. name' calls a function (defined with function) with POSIX semantics (instead of ksh semantics). in pdksh, . does not call functions. + - test: "test -f foo bar blah" is the same as "test -f foo" (the extra + arguments, of which there must be at least 2, are ignored) - pdksh + generates an error message (unexpected operator/operand "bar") as it + should. Sometimes used to test file globs (e.g., if test -f *.o; ...). + - if the command 'sleep 5 && /bin/echo blah' is run interactively and + is the sleep is stopped (^Z), the echo is run immediately in pdksh. + In at&t ksh, the whole thing is stopped. Known differences between pdksh & at&t ksh (that are not likely to change) - at&t ksh seems to catch or ignore SIGALRM - pdksh dies upon receipt diff --git a/bin/pdksh/PROJECTS b/bin/pdksh/PROJECTS index 271dc3ccad9..917960ca4a0 100644 --- a/bin/pdksh/PROJECTS +++ b/bin/pdksh/PROJECTS @@ -1,4 +1,4 @@ -$OpenBSD: PROJECTS,v 1.2 1996/08/19 20:08:44 downsj Exp $ +$OpenBSD: PROJECTS,v 1.3 1996/10/01 02:05:30 downsj Exp $ Things to be done in pdksh (see also the NOTES file): @@ -110,7 +110,3 @@ Things to be done in pdksh (see also the NOTES file): * teach shf_vfprintf() about long long's (%lld); also make %p use long longs if appropriate. - - * add \[...\] parsing to prompt printing (don't count width of chars - inside the \[..\] - used to keep escape sequences in prompts from - messing up command-line-editor's idea of where the cursor is) diff --git a/bin/pdksh/README b/bin/pdksh/README index 86575be9c34..032fadafd55 100644 --- a/bin/pdksh/README +++ b/bin/pdksh/README @@ -1,6 +1,6 @@ -$OpenBSD: README,v 1.2 1996/08/19 20:08:44 downsj Exp $ +$OpenBSD: README,v 1.3 1996/10/01 02:05:31 downsj Exp $ -Last updated August '96 for pdksh-5.2.8. +Last updated September '96 for pdksh-5.2.9. (check ftp://ftp.cs.mun.ca:/pub/pdksh/ or http://www.cs.mun.ca/~michael/pdksh/ for new versions/patches) @@ -57,6 +57,7 @@ Compiling/Installing: make check # optional make install # will install /usr/local/bin/ksh # and /usr/local/man/man1/ksh.1 + [add path-to-installed-pdksh to /etc/shells] The more detailed description: * run "configure --help | your-favorite-pager" and look at the @@ -106,19 +107,43 @@ Compiling/Installing: * On Linux (red hat distribution), check that /dev/tty has mode 0666 (not mode 0644). If it has the wrong permissions, ksh will print warnings about not being able to do job control. + * on NeXT machines (3.2, probably other releases), the siglist.out file + won't be generated correctly if you try to use the system's compiler + (it has a broken cc -E and strange header files). There are two + ways to make it work: + 1) if you have gcc, use it (for everything). Alternatively, + force configure to use it for CPP, i.e., use + CPP="gcc -E" configure ... + 2) Force configure to use some extra CPPFLAGS, using + CPPFLAGS="XXX" configure ... + where XXX is obtained from running "cc -v YYY.c" on some + C file. Look at the options passed to cpp (there are lots + of them...) and replace the XXX above with them. + Make sure you do a "make distclean" (or "rm config.cache") if + you re-run configure with a difference CPP or CPPFLAGS. + Also note that if you are building multiple arch binaries, you + will have to specify both CC and CPP. * run make: everything should compile and link without problems. - * run make check: this fires up a perl script that checks for some - known and some fixed bugs. The script prints pass/fail for tests - it expected to pass/fail, and PASS/FAIL for tests it expected to - fail/pass. + * run make check: this fires up a perl script that checks for some known + and some fixed bugs. The script prints pass/fail for tests it expected + 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 + instead. * run make install: this installs ksh (in /usr/local/bin/ksh by default, or where ever you told configure to put things). + * add path-to-installed-pdksh to /etc/shells if it's not already there. + This is only needed if you intend to use pdksh as a login shell (things + like ftp won't allow users to connect in if their shell isn't in this + file). The following is a list of machines that pdksh is reported to work on: - -/PC Linux 1.x + -/PC Linux 1.x,2.x -/PC NetBSD 0.9a -/PC BSDI 1.1 -/PC FreeBSD 2.0, 2.1 + -/PC OpenBSD -/PC Interactive/Sunsoft 3.0.1 and 4.1 (note that problems have been reported with isc3.2 - see the BUG-REPORTS file) -/PC OS/2 @@ -126,12 +151,12 @@ The following is a list of machines that pdksh is reported to work on: Dec/alpha OSF/1 v2.x, v3.x Dec/alpha NetBSD 1.1B Dec/pmax Ultrix 4.2 - Dec/vax Ultrix 2.2 - Dec/vax 4.3BSD+NFS (MtXinu) + Dec/vax Ultrix 2.2 (not tested recently :-)) + Dec/vax 4.3BSD+NFS (MtXinu) (not tested recently :-)) HP/pa HP-UX 9.01 IBM/RS/6000 AIX 3.2.5 MIPS/m120 RISC/os 5.0 (bsd43 environ) - NeXT NeXTStep 3.2(?) + NeXT NeXTStep 3.2 Sun/sun4 SunOS 4.1.3, 4.1.4 Sun/sun4 Solaris 2.x Sun/sun386i SunOS 4.0.2 @@ -155,9 +180,9 @@ If you are reporting a bug (with or without a fix), please include * and a description of how to repeat the bug (a small shell script that demonstrates the bug is best). as well as the following, if relevant (if you aren't sure, include them) - * what options you are using (both options.h options and set -o options) + * what options you are using (both configure options and set -o options) * the output of configure, with the verbose flag - (eg, ./configure --verbose) + (eg, make distclean; ./configure --verbose) * the contents of config.log (this is created by the configure script) * if you are using gcc (the GNU C compiler), which version it is. diff --git a/bin/pdksh/c_ksh.c b/bin/pdksh/c_ksh.c index 30832ecb4d3..a08ec31ae1c 100644 --- a/bin/pdksh/c_ksh.c +++ b/bin/pdksh/c_ksh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ksh.c,v 1.3 1996/08/25 12:37:55 downsj Exp $ */ +/* $OpenBSD: c_ksh.c,v 1.4 1996/10/01 02:05:32 downsj Exp $ */ /* * built-in Korn commands: c_* @@ -394,13 +394,17 @@ c_print(wp) for (s = Xstring(xs, xp); len > 0; ) { n = write(fd, s, len); if (n < 0) { +#ifdef KSH if (flags & PO_COPROC) restore_pipe(opipe); +#endif /* KSH */ if (errno == EINTR) { /* allow user to ^C out */ intrcheck(); +#ifdef KSH if (flags & PO_COPROC) opipe = block_pipe(); +#endif /* KSH */ continue; } #ifdef KSH @@ -985,6 +989,7 @@ c_unalias(wp) return rv; } +#ifdef KSH int c_let(wp) char **wp; @@ -1003,6 +1008,7 @@ c_let(wp) rv = val == 0; return rv; } +#endif /* KSH */ int c_jobs(wp) @@ -1370,7 +1376,9 @@ const struct builtin kshbuiltins [] = { {"+getopts", c_getopts}, {"+jobs", c_jobs}, {"+kill", c_kill}, +#ifdef KSH {"let", c_let}, +#endif /* KSH */ {"print", c_print}, {"pwd", c_pwd}, {"*=readonly", c_typeset}, diff --git a/bin/pdksh/edit.c b/bin/pdksh/edit.c index 12e4fed77d5..c05109c859d 100644 --- a/bin/pdksh/edit.c +++ b/bin/pdksh/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.2 1996/08/19 20:08:47 downsj Exp $ */ +/* $OpenBSD: edit.c,v 1.3 1996/10/01 02:05:33 downsj Exp $ */ /* * Command line editing - common code @@ -52,6 +52,7 @@ x_init() if (setsig(&sigtraps[SIGWINCH], x_sigwinch, SS_RESTORE_ORIG|SS_SHTRAP)) sigtraps[SIGWINCH].flags |= TF_SHELL_USES; # endif /* SIGWINCH */ + got_sigwinch = 1; /* force initial check */ check_sigwinch(); #endif /* TIOCGWINSZ */ @@ -308,7 +309,6 @@ x_mode(onoff) * RETURN VALUE: * length */ - int promptlen(cp, spp) const char *cp; @@ -316,37 +316,35 @@ promptlen(cp, spp) { int count = 0; const char *sp = cp; + char delimiter = 0; + int indelimit = 0; + + /* Undocumented AT&T ksh feature: + * If the second char in the prompt string is \r then the first char + * is taken to be a non-printing delimiter and any chars between two + * instances of the delimiter are not considered to be part of the + * prompt length + */ + if (*cp && cp[1] == '\r') { + delimiter = *cp; + cp += 2; + } - while (*cp) { - if (*cp == '\n' || *cp == '\r') { + for (; *cp; cp++) { + if (indelimit && *cp != delimiter) + ; + else if (*cp == '\n' || *cp == '\r') { count = 0; - cp++; - sp = cp; + sp = cp + 1; } else if (*cp == '\t') { count = (count | 7) + 1; - cp++; } else if (*cp == '\b') { if (count > 0) count--; - cp++; - } -#if 1 + } else if (*cp == delimiter) + indelimit = !indelimit; else - cp++, count++; -#else - else if (*cp++ != '!') - count++; - else if (*cp == '!') { - cp++; count++; - } else { - register int i = source->line + 1; - - do - count++; - while ((i /= 10) > 0); - } -#endif /* 1 */ } if (spp) *spp = sp; @@ -822,6 +820,7 @@ add_glob(str, slen) { char *toglob; char *s; + bool_t saw_slash = FALSE; if (slen < 0) return (char *) 0; @@ -831,8 +830,9 @@ add_glob(str, slen) /* * If the pathname contains a wildcard (an unquoted '*', - * '?', or '[') or parameter expansion ('$'), then it is globbed - * based on that value (i.e., without the appended '*'). + * '?', or '[') or parameter expansion ('$'), or a ~username + * with no trailing slash, then it is globbed based on that + * value (i.e., without the appended '*'). */ for (s = toglob; *s; s++) { if (*s == '\\' && s[1]) @@ -840,8 +840,10 @@ add_glob(str, slen) else if (*s == '*' || *s == '[' || *s == '?' || *s == '$' || (s[1] == '(' /*)*/ && strchr("*+?@!", *s))) break; + else if (ISDIRSEP(*s)) + saw_slash = TRUE; } - if (!*s) { + if (!*s && (*toglob != '~' || saw_slash)) { toglob[slen] = '*'; toglob[slen + 1] = '\0'; } diff --git a/bin/pdksh/exec.c b/bin/pdksh/exec.c index 32e2024206a..345b68df31a 100644 --- a/bin/pdksh/exec.c +++ b/bin/pdksh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.3 1996/08/25 12:38:00 downsj Exp $ */ +/* $OpenBSD: exec.c,v 1.4 1996/10/01 02:05:34 downsj Exp $ */ /* * execute command tree @@ -521,7 +521,7 @@ comexec(t, tp, ap, flags) fcflags |= FC_DEFPATH; } ap += builtin_opt.optind; - /* POSIX says special builtins loose their status + /* POSIX says special builtins lose their status * if accessed using command. */ keepasn_ok = 0; diff --git a/bin/pdksh/ksh.1 b/bin/pdksh/ksh.1 index 6b0721aecdb..7f6e1987bdd 100644 --- a/bin/pdksh/ksh.1 +++ b/bin/pdksh/ksh.1 @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: ksh.1,v 1.2 1996/08/19 20:08:53 downsj Exp $ +.\" $OpenBSD: ksh.1,v 1.3 1996/10/01 02:05:37 downsj Exp $ .\"{{{}}} .\"{{{ Notes about man page .\" - use the pseudo-macros .sh( and .sh) to begin and end sh-specific @@ -18,7 +18,7 @@ .\" function) for more clear description. .\"}}} .\"{{{ Title -.TH KSH 1 "May 19, 1995" "" "User commands" +.TH KSH 1 "August 19, 1995" "" "User commands" .\"}}} .\"{{{ Name .SH NAME @@ -138,9 +138,9 @@ used to specify redirections (see Input/Output Redirection below); \fB&\fP is used to create asynchronous pipelines; \fB&&\fP and \fB||\fP are used to specify conditional execution; \fB;;\fP is used in \fBcase\fP statements; -\fB(\fP .. \fB)\fP are used to create subshells; -and lastly, \fB((\fP .. \fB))\fP are used in arithmetic expressions; +and lastly, +\fB(\fP .. \fB)\fP are used to create subshells. .PP White-space and meta-characters can be quoted individually using backslash (\fB\e\fP), or in groups using double (\fB"\fP) or single (\fB'\fP) @@ -180,7 +180,9 @@ The command may be a shell built-in command, a function or an \fIexternal command\fP, \fIi.e.\fP, a separate executable file that is located using the \fBPATH\fP parameter (see Command Execution below). Note that all command constructs have an \fIexit status\fP: for external -commands, this is related to the status returned by \fIwait\fP(2); +commands, this is related to the status returned by \fIwait\fP(2) (if the +command could not be found, the exit status is 127, if it could not be +executed, the exit status is 126); the exit status of other command constructs (built-in commands, functions, compound-commands, pipelines, lists, \fIetc.\fP) are all well defined and are described where the construct is described. @@ -888,6 +890,15 @@ The process ID of the shell's parent (readonly). Parameter, command and arithmetic substitutions are performed, and \fB!\fP is replaced with the current command number (see \fBfc\fP command below). A literal ! can be put in the prompt by placing !! in PS1. +Note that since the command line editors try to figure out how long the +prompt is (so they know how far it is to edge of the screen), +escape codes in the prompt tend to mess things up. +You can tell the shell not to count certain sequences (such as escape codes) +by prefixing your prompt with a non-printing character (such as control-A) +followed by a carriage return and then delimiting the escape codes with +this non-printing character. +If you don't have any non-printing characters, you're out of luck... +BTW, don't blame me for this hack; it's in the original ksh. Default is `\fB$\ \fP' for non-root users, `\fB#\ \fP' for root.. .\"}}} .\"{{{ PS2 @@ -1195,6 +1206,17 @@ negation. logical not; the result is 1 if argument is zero, 0 if not. .IP "\fB~\fP" arithmetic (bit-wise) not. +.IP "\fB++\fP" +increment; must be applied to a parameter (not a literal or other +expression) - the parameter is incremented by 1. +When used as a prefix operator, the result is the incremented value of +the parameter, when used as a postfix operator, the result is the +original value of the parameter. +.IP "\fB++\fP" +similar to \fB++\fP, except the paramter is decremented by 1. +.IP "\fB,\fP" +seperates two arithmetic expressions; the left hand side is evaluated first, +then the right. The result is value of the expression on the right hand side. .IP "\fB=\fP" assignment; variable on the left is set to the value on the right. .IP "\fB*= /= %= += \-= <<= >>= &= ^= |=\fP" @@ -1978,6 +2000,10 @@ No effect \- in the original Korn shell, unless viraw was set, the vi command line mode would let the tty driver do the work until ESC (^[) was entered. pdksh is always in viraw mode. T} + vi-esccomplete T{ +In vi command line editing, do command / file name completion when +escape (^[) is entered in command mode. +T} vi-show8 T{ Prefix characters with the eighth bit set with `M-'. If this option is not set, characters in the range @@ -3029,11 +3055,12 @@ File name expansion matches the big-word against the files in the current directory. After expansion, the cursor is placed just past the last word and the editor is in insert mode. -.IP "\fIn\fP\fB\e\fP, \fIn\fP\fB^F\fP and \fIn\fP\fB<tab>\fP" +.IP "\fIn\fP\fB\e\fP, \fIn\fP\fB^F\fP, \fIn\fP\fB<tab>\fP and \fIn\fP\fB<esc>\fP" command/file name completion: replace the current big-word with the longest unique match obtained after performing command/file name expansion. -\fB<tab>\fP is only recognized if the \fBvi-tabcomplete\fP option +\fB<tab>\fP is only recognized if the \fBvi-tabcomplete\fP option is set, +while \fB<esc>\fP is only recognized if the \fBvi-esccomplete\fP option is set (see \fBset \-o\fP). If \fIn\fP is specified, the \fIn\fPth possible completion is selected (as reported by the command/file name enumeration diff --git a/bin/pdksh/ksh_stat.h b/bin/pdksh/ksh_stat.h index 447b7b3f385..1abcc7cb1fc 100644 --- a/bin/pdksh/ksh_stat.h +++ b/bin/pdksh/ksh_stat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ksh_stat.h,v 1.2 1996/08/19 20:08:54 downsj Exp $ */ +/* $OpenBSD: ksh_stat.h,v 1.3 1996/10/01 02:05:39 downsj Exp $ */ /* Wrapper around the ugly sys/stat includes/ifdefs */ @@ -31,8 +31,8 @@ #if !defined(S_ISBLK) && defined(S_IFBLK) # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) #endif /* S_ISBLK */ -#if !defined(S_ISFIFO) && defined(S_IFFIFO) -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFFIFO) +#if !defined(S_ISFIFO) && defined(S_IFIFO) +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) #endif /* S_ISFIFO */ #if !defined(S_ISLNK) && defined(S_IFLNK) # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) diff --git a/bin/pdksh/ksh_time.h b/bin/pdksh/ksh_time.h index 21e98b9d147..ee8dc9b9128 100644 --- a/bin/pdksh/ksh_time.h +++ b/bin/pdksh/ksh_time.h @@ -1,4 +1,7 @@ -/* $OpenBSD: ksh_time.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */ +/* $OpenBSD: ksh_time.h,v 1.2 1996/10/01 02:05:40 downsj Exp $ */ + +#ifndef KSH_TIME_H +# define KSH_TIME_H /* Wrapper around the ugly time.h,sys/time.h includes/ifdefs */ @@ -20,3 +23,4 @@ extern time_t time ARGS((time_t *)); #ifndef CLK_TCK # define CLK_TCK 60 /* 60HZ */ #endif +#endif /* KSH_TIME_H */ diff --git a/bin/pdksh/ksh_times.h b/bin/pdksh/ksh_times.h index 45f1b793821..ec7b97eedf5 100644 --- a/bin/pdksh/ksh_times.h +++ b/bin/pdksh/ksh_times.h @@ -1,4 +1,10 @@ -/* $OpenBSD: ksh_times.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */ +/* $OpenBSD: ksh_times.h,v 1.2 1996/10/01 02:05:41 downsj Exp $ */ + +#ifndef KSH_TIMES_H +# define KSH_TIMES_H + +/* Needed for clock_t on some systems (ie, NeXT in non-posix mode) */ +#include "ksh_time.h" #include <sys/times.h> @@ -11,3 +17,4 @@ extern clock_t ksh_times ARGS((struct tms *)); #ifdef HAVE_TIMES extern clock_t times ARGS((struct tms *)); #endif /* HAVE_TIMES */ +#endif /* KSH_TIMES_H */ diff --git a/bin/pdksh/lex.c b/bin/pdksh/lex.c index 74ed0748fef..356d164e935 100644 --- a/bin/pdksh/lex.c +++ b/bin/pdksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.2 1996/08/19 20:08:55 downsj Exp $ */ +/* $OpenBSD: lex.c,v 1.3 1996/10/01 02:05:42 downsj Exp $ */ /* * lexical analysis and source input @@ -54,11 +54,14 @@ yylex(cf) if (cf&ONEWORD) istate = SWORD; +#ifdef KSH else if (cf&LETEXPR) { *wp++ = OQUOTE; /* enclose arguments in (double) quotes */ istate = SDPAREN; ndparen = 0; - } else { /* normal lexing */ + } +#endif /* KSH */ + else { /* normal lexing */ istate = (cf & HEREDELIM) ? SHEREDELIM : SBASE; while ((c = getsc()) == ' ' || c == '\t') ; @@ -411,6 +414,7 @@ yylex(cf) case SWORD: /* ONEWORD */ goto Subst; +#ifdef KSH case SDPAREN: /* LETEXPR: (( ... )) */ /*(*/ if (c == ')') { @@ -430,6 +434,7 @@ yylex(cf) */ ++ndparen; goto Sbase2; +#endif /* KSH */ case SHEREDELIM: /* <<,<<- delimiter */ /* XXX chuck this state (and the next) - use @@ -561,10 +566,12 @@ Done: return c; case '(': /*)*/ +#ifdef KSH if ((c2 = getsc()) == '(') /*)*/ c = MDPAREN; else ungetsc(c2); +#endif /* KSH */ return c; /*(*/ case ')': @@ -574,7 +581,11 @@ Done: *wp++ = EOS; /* terminate word */ yylval.cp = Xclose(ws, wp); - if (state == SWORD || state == SDPAREN) /* ONEWORD? */ + if (state == SWORD +#ifdef KSH + || state == SDPAREN +#endif /* KSH */ + ) /* ONEWORD? */ return LWORD; ungetsc(c); /* unget terminator */ @@ -1056,12 +1067,8 @@ pprompt(cp, ntruncate) shf_putc(c, shl_out); } #endif /* 0 */ - if (ntruncate) - shellf("%.*s", ntruncate, cp); - else { - shf_puts(cp, shl_out); - shf_flush(shl_out); - } + shf_puts(cp + ntruncate, shl_out); + shf_flush(shl_out); } /* Read the variable part of a ${...} expression (ie, up to but not including diff --git a/bin/pdksh/lex.h b/bin/pdksh/lex.h index f4517db927f..8d755ca031d 100644 --- a/bin/pdksh/lex.h +++ b/bin/pdksh/lex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */ +/* $OpenBSD: lex.h,v 1.2 1996/10/01 02:05:43 downsj Exp $ */ /* * Source input, lexer and parser @@ -51,7 +51,9 @@ struct source { */ #define SBASE 0 /* outside any lexical constructs */ #define SWORD 1 /* implicit quoting for substitute() */ +#ifdef KSH #define SDPAREN 2 /* inside (( )), implicit quoting */ +#endif /* KSH */ #define SSQUOTE 3 /* inside '' */ #define SDQUOTE 4 /* inside "" */ #define SBRACE 5 /* inside ${} */ @@ -93,7 +95,9 @@ typedef union { #define FUNCTION 274 #define TIME 275 #define REDIR 276 +#ifdef KSH #define MDPAREN 277 /* (( )) */ +#endif /* KSH */ #define BANG 278 /* ! */ #define DBRACKET 279 /* [[ .. ]] */ #define COPROC 280 /* |& */ diff --git a/bin/pdksh/main.c b/bin/pdksh/main.c index 74118b7f037..ad3cce92323 100644 --- a/bin/pdksh/main.c +++ b/bin/pdksh/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.2 1996/08/19 20:08:56 downsj Exp $ */ +/* $OpenBSD: main.c,v 1.3 1996/10/01 02:05:45 downsj Exp $ */ /* * startup, main loop, enviroments and error handling @@ -57,7 +57,9 @@ static const char *const initcoms [] = { #ifdef KSH "autoload=typeset -fu", "functions=typeset -f", +# ifdef HISTORY "history=fc -l", +# endif /* HISTORY */ "integer=typeset -i", "nohup=nohup ", "local=typeset", @@ -356,7 +358,7 @@ main(argc, argv) include(substitute("$HOME/profile.ksh", 0), 0, (char **) 0, 1); #else /* OS2 */ - include("/etc/profile", 0, (char **) 0, 1); + include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1); if (!Flag(FPRIVILEGED)) include(substitute("$HOME/.profile", 0), 0, (char **) 0, 1); diff --git a/bin/pdksh/options.h b/bin/pdksh/options.h deleted file mode 100644 index 0c83c904dbc..00000000000 --- a/bin/pdksh/options.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $OpenBSD: options.h,v 1.2 1996/08/25 11:56:34 downsj Exp $ */ - -/* - * Options configuration file for the PD ksh - */ - -/* Define this to the path to use if the PATH environment variable is - * not set (ie, either never set or explicitly unset with the unset - * command). A value without . in it is safest. - * THIS DEFINE IS NOT USED if confstr() and _CS_PATH are available or - * if <paths.h> defines _PATH_DEFPATH. - */ -#ifdef OS2 -# define DEFAULT_PATH "c:/usr/bin;c:/os2;/os2" /* OS/2 only */ -#else /* OS2 */ -# define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb" /* Unix */ -#endif /* OS2 */ - - -/* Define KSH to get KSH features; otherwise, you get a fairly basic - * Bourne/POSIXish shell (undefining this results in EMACS, VI and - * COMPLEX_HISTORY being undefined as well, regardless of their setting - * here). - */ -/* #define KSH */ - -/* Define EMACS if you want emacs command line editing compiled in (enabled - * with "set -o emacs", or by setting the VISUAL or EDITOR variables to - * something ending in emacs). - */ -#define EMACS - -/* Define VI if you want vi command line editing compiled in (enabled with - * "set -o vi", or by setting the VISUAL or EDITOR variables to something - * ending in vi). - */ -#define VI - -/* Define JOBS if you want job control compiled in. This requires that your - * system support process groups and reliable signal handling routines (it - * will be automatically undefined if your system doesn't have them). - */ -#define JOBS - -/* Define BRACE_EXPAND if you want csh-like {} globbing compiled in and enabled - * (can be disabled with "set +o braceexpand"; also disabled by "set -o posix", - * but can be re-enabled with "set -o braceexpand"). - */ -#define BRACE_EXPAND - -/* Define COMPLEX_HISTORY if you want at&t ksh style history files (ie, file - * is updated after each command is read; concurrent ksh's read each other's - * commands, etc.). This option uses the mmap() and flock() functions - if - * these aren't available, the option is automatically undefined. If this - * option is not defined, a simplier history mechanism which reads/saves the - * history at startup/exit time, respectively, is used. COMPLEX_HISTORY is - * courtesy of Peter Collinson. - */ -#undef COMPLEX_HISTORY - -/* Define POSIXLY_CORRECT if you want POSIX behavior by default (otherwise, - * posix behavior is only turned on if the environment variable POSIXLY_CORRECT - * is present or by using "set -o posix"; it can be turned off with - * "set +o posix"). - * See the POSIX Mode section in the man page for details on what this option - * affects. - * NOTE: posix mode is not compatable with some bourne sh/at&t ksh scripts. - */ -#undef POSIXLY_CORRECT - -/* Define DEFAULT_ENV to be the name of the file (eg, "/etc/default.env") to - * include if the ENV environment variable is not set when the shell starts - * up. This can be useful when used with rsh(1) which creates a non-login - * shell (ie, profile not read) with an empty environment (ie, ENV not set). - * Setting ENV to null disables the inclusion of DEFAULT_ENV. - * NOTE: this is a non-standard feature (ie, at&t ksh has no default - * environment) - undefining this disables the use of a default ENV file. - */ -#undef DEFAULT_ENV - -/* Define SWTCH to handle SWITCH character, for use with shell layers (shl(1)). - * This has not been tested for some time. - */ -#undef SWTCH - -/* SILLY: The name says it all - compile game of life code into the emacs - * command line editing code. - */ -#undef SILLY diff --git a/bin/pdksh/sh.h b/bin/pdksh/sh.h index f6578427d9c..b05a49d896e 100644 --- a/bin/pdksh/sh.h +++ b/bin/pdksh/sh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sh.h,v 1.2 1996/08/19 20:08:58 downsj Exp $ */ +/* $OpenBSD: sh.h,v 1.3 1996/10/01 02:05:47 downsj Exp $ */ /* * Public Domain Bourne/Korn shell @@ -682,6 +682,14 @@ EXTERN int x_cols I__(80); /* tty columns */ #define OBRACE '{' #define CBRACE '}' +/* Determine the location of the system (common) profile */ +#ifndef KSH_SYSTEM_PROFILE +# ifdef __NeXT +# define KSH_SYSTEM_PROFILE "/etc/profile.std" +# else /* __NeXT */ +# define KSH_SYSTEM_PROFILE "/etc/profile" +# endif /* __NeXT */ +#endif /* KSH_SYSTEM_PROFILE */ #include "shf.h" #include "table.h" diff --git a/bin/pdksh/siglist.sh b/bin/pdksh/siglist.sh index 420aaf6dd05..135e920d637 100644 --- a/bin/pdksh/siglist.sh +++ b/bin/pdksh/siglist.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: siglist.sh,v 1.1 1996/08/14 06:19:11 downsj Exp $ +# $OpenBSD: siglist.sh,v 1.2 1996/10/01 02:05:48 downsj Exp $ # # Script to generate a sorted, complete list of signals, suitable @@ -25,16 +25,18 @@ CPP="${1-cc -E}" #endif/') > $in $CPP $in > $out sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n | - sed 's/^[0-9]* //' | - awk 'BEGIN { last=0; nsigs=0; } - { - n = $2; - if (n > 0 && n != last) { - while (++last < n) { - printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last; - } - print; + sed 's/^[0-9]* //' | + awk 'BEGIN { last=0; nsigs=0; } + { + if ($2 ~ /^[0-9][0-9]*$/ && $3 == ",") { + n = $2; + if (n > 0 && n != last) { + while (++last < n) { + printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last; } - }' | - tr '`' '"' | grep -v '"DUMMY"' + print; + } + } + }' | + tr '`' '"' | grep -v '"DUMMY"' ecode=0 diff --git a/bin/pdksh/syn.c b/bin/pdksh/syn.c index 8779c315841..c45d449d993 100644 --- a/bin/pdksh/syn.c +++ b/bin/pdksh/syn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syn.c,v 1.2 1996/08/19 20:08:59 downsj Exp $ */ +/* $OpenBSD: syn.c,v 1.3 1996/10/01 02:05:50 downsj Exp $ */ /* * shell parser (C version) @@ -284,6 +284,7 @@ get_command(cf) t = nested(TBRACE, '{', '}'); break; +#ifdef KSH case MDPAREN: { static const char let_cmd[] = { CHAR, 'l', CHAR, 'e', @@ -296,6 +297,7 @@ get_command(cf) XPput(args, yylval.cp); break; } +#endif /* KSH */ #ifdef KSH case DBRACKET: /* [[ .. ]] */ @@ -658,8 +660,8 @@ const struct tokeninfo { { "&&", LOGAND, FALSE }, { "||", LOGOR, FALSE }, { ";;", BREAK, FALSE }, - { "((", MDPAREN, FALSE }, #ifdef KSH + { "((", MDPAREN, FALSE }, { "|&", COPROC, FALSE }, #endif /* KSH */ /* and some special cases... */ diff --git a/bin/pdksh/tests/regress.t b/bin/pdksh/tests/regress.t index d78a02641de..218fc55249a 100644 --- a/bin/pdksh/tests/regress.t +++ b/bin/pdksh/tests/regress.t @@ -663,3 +663,22 @@ expected-stdout: OPTARG=x, OPTIND=3, optc=?. done --- + +name: regression-45 +description: + Parameter assignments with [] recognized correctly +stdin: + FOO=*[12] + BAR=abc[ + MORE=[abc] + JUNK=a[bc + echo "<$FOO>" + echo "<$BAR>" + echo "<$MORE>" + echo "<$JUNK>" +expected-stdout: + <*[12]> + <abc[> + <[abc]> + <a[bc> +--- diff --git a/bin/pdksh/tests/unclass1.t b/bin/pdksh/tests/unclass1.t index 2e3e88791bf..55d4e58976f 100644 --- a/bin/pdksh/tests/unclass1.t +++ b/bin/pdksh/tests/unclass1.t @@ -49,7 +49,7 @@ name: xxx-exec-environment-1 description: Check to see if exec sets it's environment correctly stdin: - FOO=bar exec printenv + FOO=bar exec env expected-stdout-pattern: /(^|.*\n)FOO=bar\n/ --- @@ -59,8 +59,8 @@ description: Check to make sure exec doesn't change environment if a program isn't exec-ed stdin: - printenv > bar1 - FOO=bar exec; printenv > bar2 + env > bar1 + FOO=bar exec; env > bar2 cmp -s bar1 bar2 --- diff --git a/bin/pdksh/tests/version.t b/bin/pdksh/tests/version.t index 0ec6fbac7b5..e1b8127fcbc 100644 --- a/bin/pdksh/tests/version.t +++ b/bin/pdksh/tests/version.t @@ -4,5 +4,5 @@ description: stdin: echo $KSH_VERSION expected-stdout: - @(#)PD KSH v5.2.8 96/08/19 + @(#)PD KSH v5.2.9 96/09/30 --- diff --git a/bin/pdksh/tty.c b/bin/pdksh/tty.c index 5ee19fbba1d..00a94cd3ae6 100644 --- a/bin/pdksh/tty.c +++ b/bin/pdksh/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.1 1996/08/14 06:19:12 downsj Exp $ */ +/* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */ #include "sh.h" #include "ksh_stat.h" @@ -114,11 +114,30 @@ tty_init(init_ttystate) /* SCO can't job control on /dev/tty, so don't try... */ #if !defined(__SCO__) if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) { +#ifdef __NeXT + /* rlogin on NeXT boxes does not set up the controlling tty, + * so force it to be done here... + */ + { + extern char *ttyname ARGS((int)); + char *s = ttyname(isatty(2) ? 2 : 0); + int fd; + + if (s && (fd = open(s, O_RDWR, 0)) >= 0) { + close(fd); + tfd = open("/dev/tty", O_RDWR, 0); + } + } +#endif /* __NeXT */ + /* X11R5 xterm on mips doesn't set controlling tty properly - temporary hack */ # if !defined(__mips) || !(defined(_SYSTYPE_BSD43) || defined(__SYSTYPE_BSD43)) - tty_devtty = 0; - warningf(FALSE, "No controlling tty (open /dev/tty: %s)", - strerror(errno)); + if (tfd < 0) { + tty_devtty = 0; + warningf(FALSE, + "No controlling tty (open /dev/tty: %s)", + strerror(errno)); + } # endif /* __mips */ } #else /* !__SCO__ */ diff --git a/bin/pdksh/var.c b/bin/pdksh/var.c index b31b41d48a1..09ec84f0e3b 100644 --- a/bin/pdksh/var.c +++ b/bin/pdksh/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.2 1996/08/19 20:09:02 downsj Exp $ */ +/* $OpenBSD: var.c,v 1.3 1996/10/01 02:05:53 downsj Exp $ */ #include "sh.h" #include "ksh_time.h" @@ -757,7 +757,7 @@ skip_wdvarname(s, aok) do s += 2; while (s[0] == CHAR && letnum(s[1])); - if (aok) { + if (aok && s[0] == CHAR && s[1] == '[') { /* skip possible array de-reference */ const char *p = s; char c; @@ -1013,9 +1013,9 @@ unsetspec(vp) break; #endif /* KSH */ /* todo: generic action for specials (at&t says variables - * loose their special meaning when unset but global() checks + * lose their special meaning when unset but global() checks * the name of new vars to see if they are special) - * loose meaning: _, ERRNO, LINENO, MAILCHECK, + * lose meaning: _, ERRNO, LINENO, MAILCHECK, * OPTARG, OPTIND, RANDOM, SECONDS, TMOUT. * unknown: MAIL, MAILPATH, HISTSIZE, HISTFILE, * no effect: IFS, COLUMNS, PATH, TMPDIR, diff --git a/bin/pdksh/version.c b/bin/pdksh/version.c index edd71480d4c..d22e8f1ec29 100644 --- a/bin/pdksh/version.c +++ b/bin/pdksh/version.c @@ -1,4 +1,4 @@ -/* $OpenBSD: version.c,v 1.2 1996/08/19 20:09:03 downsj Exp $ */ +/* $OpenBSD: version.c,v 1.3 1996/10/01 02:05:54 downsj Exp $ */ /* * value of $KSH_VERSION (or $SH_VERSION) @@ -7,4 +7,4 @@ #include "sh.h" const char ksh_version [] = - "@(#)PD KSH v5.2.8 96/08/19"; + "@(#)PD KSH v5.2.9 96/09/30"; |