commit: ebf8b073f16652a0f6c01f7e019ec194828a4927
parent: 5858a92b6dfbb67087a8b0f396964acc66ccb4e0
author: Brian Callahan <bcallah@openbsd.org>
date: Thu, 3 Aug 2023 18:27:14 -0400
Bring in post-7.3 commits
12 files changed, 138 insertions(+), 119 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -1,46 +1,46 @@
/config.h/1.19/Tue Jan 16 02:21:56 2018//
-/c_test.c/1.27/Result of merge//
-/edit.c/1.69/Result of merge//
/io.c/1.38/Result of merge//
/history.c/1.84/Result of merge//
/trap.c/1.33/Tue Dec 17 00:39:35 2019//
-/sh.h/1.76/Result of merge//
-/eval.c/1.66/Result of merge//
-/var.c/1.72/Result of merge//
/vi.c/1.60/Result of merge+Fri Mar 12 03:48:27 2021//
-/emacs.c/1.89/Result of merge//
/tty.c/1.19/Result of merge//
/misc.c/1.78/Result of merge//
-/exec.c/1.76/Result of merge//
-/main.c/1.99/Result of merge+Sat Feb 11 15:37:02 2023//
-/CONTRIBUTORS/1.11/Sun Apr 16 23:03:22 2023//
-/LEGAL/1.2/Sun Apr 16 23:03:22 2023//
-/Makefile/1.39/Sun Apr 16 23:03:29 2023//
-/NOTES/1.16/Sun Apr 16 23:03:22 2023//
-/PROJECTS/1.9/Sun Apr 16 23:03:22 2023//
-/README/1.16/Sun Apr 16 23:03:29 2023//
-/alloc.c/1.19/Sun Apr 16 23:03:22 2023//
-/c_ksh.c/1.62/Sun Apr 16 23:03:22 2023//
-/c_sh.c/1.64/Sun Apr 16 23:03:22 2023//
-/c_test.h/1.4/Sun Apr 16 23:03:22 2023//
-/c_ulimit.c/1.29/Sun Apr 16 23:03:22 2023//
-/edit.h/1.12/Sun Apr 16 23:03:22 2023//
-/expand.h/1.15/Sun Apr 16 23:03:22 2023//
-/expr.c/1.34/Sun Apr 16 23:03:22 2023//
-/jobs.c/1.62/Sun Apr 16 23:03:22 2023//
-/ksh.1/1.218/Sun Apr 16 23:03:22 2023//
-/lex.c/1.79/Sun Apr 16 23:03:22 2023//
-/lex.h/1.21/Sun Apr 16 23:03:22 2023//
-/mail.c/1.27/Sun Apr 16 23:03:22 2023//
-/path.c/1.23/Sun Apr 16 23:03:22 2023//
-/sh.1/1.156/Sun Apr 16 23:03:22 2023//
-/shf.c/1.34/Sun Apr 16 23:03:22 2023//
-/shf.h/1.8/Sun Apr 16 23:03:22 2023//
-/syn.c/1.40/Sun Apr 16 23:03:22 2023//
-/table.c/1.25/Sun Apr 16 23:03:22 2023//
-/table.h/1.15/Sun Apr 16 23:03:22 2023//
-/tree.c/1.34/Sun Apr 16 23:03:22 2023//
-/tree.h/1.12/Sun Apr 16 23:03:22 2023//
-/tty.h/1.6/Sun Apr 16 23:03:22 2023//
-/version.c/1.12/Sun Apr 16 23:03:22 2023//
+/CONTRIBUTORS/1.11/Thu Aug 3 22:00:56 2023//
+/LEGAL/1.2/Thu Aug 3 22:00:56 2023//
+/Makefile/1.39/Thu Aug 3 22:25:58 2023//
+/NOTES/1.16/Thu Aug 3 22:00:56 2023//
+/PROJECTS/1.9/Thu Aug 3 22:00:56 2023//
+/README/1.16/Thu Aug 3 22:25:58 2023//
+/alloc.c/1.19/Thu Aug 3 22:00:56 2023//
+/c_ksh.c/1.62/Thu Aug 3 22:00:56 2023//
+/c_sh.c/1.64/Thu Aug 3 22:00:56 2023//
+/c_test.c/1.28/Result of merge//
+/c_test.h/1.4/Thu Aug 3 22:00:56 2023//
+/c_ulimit.c/1.29/Thu Aug 3 22:00:56 2023//
+/edit.c/1.70/Result of merge//
+/edit.h/1.13/Thu Aug 3 22:25:58 2023//
+/emacs.c/1.90/Result of merge//
+/eval.c/1.67/Result of merge//
+/exec.c/1.77/Result of merge//
+/expand.h/1.15/Thu Aug 3 22:00:56 2023//
+/expr.c/1.34/Thu Aug 3 22:00:56 2023//
+/jobs.c/1.62/Thu Aug 3 22:00:56 2023//
+/ksh.1/1.219/Thu Aug 3 22:25:58 2023//
+/lex.c/1.79/Thu Aug 3 22:00:56 2023//
+/lex.h/1.21/Thu Aug 3 22:00:56 2023//
+/mail.c/1.27/Thu Aug 3 22:00:56 2023//
+/main.c/1.100/Result of merge//
+/path.c/1.23/Thu Aug 3 22:00:56 2023//
+/sh.1/1.157/Thu Aug 3 22:25:58 2023//
+/sh.h/1.77/Result of merge//
+/shf.c/1.34/Thu Aug 3 22:00:56 2023//
+/shf.h/1.8/Thu Aug 3 22:00:56 2023//
+/syn.c/1.40/Thu Aug 3 22:00:56 2023//
+/table.c/1.25/Thu Aug 3 22:00:56 2023//
+/table.h/1.15/Thu Aug 3 22:00:56 2023//
+/tree.c/1.34/Thu Aug 3 22:00:56 2023//
+/tree.h/1.12/Thu Aug 3 22:00:56 2023//
+/tty.h/1.6/Thu Aug 3 22:00:56 2023//
+/var.c/1.73/Result of merge//
+/version.c/1.12/Thu Aug 3 22:00:56 2023//
D
diff --git a/c_test.c b/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */
+/* $OpenBSD: c_test.c,v 1.28 2023/06/10 07:24:21 op Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -156,12 +156,6 @@ c_test(char **wp)
}
if (argc == 1) {
opnd1 = (*te.getopnd)(&te, TO_NONOP, 1);
- /* Historically, -t by itself test if fd 1
- * is a file descriptor, but POSIX says its
- * a string test...
- */
- if (!Flag(FPOSIX) && strcmp(opnd1, "-t") == 0)
- break;
res = (*te.eval)(&te, TO_STNZE, opnd1,
NULL, 1);
if (invert & 1)
@@ -271,14 +265,11 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
case TO_FILGZ: /* -s */
return stat(opnd1, &b1) == 0 && b1.st_size > 0L;
case TO_FILTT: /* -t */
- if (opnd1 && !bi_getn(opnd1, &res)) {
+ if (!bi_getn(opnd1, &res)) {
te->flags |= TEF_ERROR;
- res = 0;
- } else {
- /* generate error if in FPOSIX mode? */
- res = isatty(opnd1 ? res : 0);
+ return 0;
}
- return res;
+ return isatty(res);
case TO_FILUID: /* -O */
return stat(opnd1, &b1) == 0 && b1.st_uid == ksheuid;
case TO_FILGID: /* -G */
@@ -527,7 +518,7 @@ static const char *
ptest_getopnd(Test_env *te, Test_op op, int do_eval)
{
if (te->pos.wp >= te->wp_end)
- return op == TO_FILTT ? "1" : NULL;
+ return NULL;
return *te->pos.wp++;
}
diff --git a/edit.c b/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.69 2019/06/28 13:34:59 deraadt Exp $ */
+/* $OpenBSD: edit.c,v 1.70 2023/06/21 22:22:08 millert Exp $ */
/*
* Command line editing - common code
@@ -300,6 +300,67 @@ static void glob_table(const char *pat, XPtrV *wp, struct table *tp);
static void glob_path(int flags, const char *pat, XPtrV *wp,
const char *path);
+static char *
+plain_fmt_entry(void *arg, int i, char *buf, int bsize)
+{
+ const char *str = ((char *const *)arg)[i];
+ char *buf0 = buf;
+ int ch;
+
+ if (buf == NULL || bsize <= 0)
+ internal_errorf("%s: buf %lx, bsize %d",
+ __func__, (long) buf, bsize);
+
+ while ((ch = (unsigned char)*str++) != '\0') {
+ if (iscntrl(ch)) {
+ if (bsize < 3)
+ break;
+ *buf++ = '^';
+ *buf++ = UNCTRL(ch);
+ bsize -= 2;
+ continue;
+ }
+ if (bsize < 2)
+ break;
+ *buf++ = ch;
+ bsize--;
+ }
+ *buf = '\0';
+
+ return buf0;
+}
+
+/* Compute the length of string taking into account escape characters. */
+static size_t
+strlen_esc(const char *str)
+{
+ size_t len = 0;
+ int ch;
+
+ while ((ch = (unsigned char)*str++) != '\0') {
+ if (iscntrl(ch))
+ len++;
+ len++;
+ }
+ return len;
+}
+
+static int
+pr_list(char *const *ap)
+{
+ char *const *pp;
+ int nwidth;
+ int i, n;
+
+ for (n = 0, nwidth = 0, pp = ap; *pp; n++, pp++) {
+ i = strlen_esc(*pp);
+ nwidth = (i > nwidth) ? i : nwidth;
+ }
+ print_columns(shl_out, n, plain_fmt_entry, (void *) ap, nwidth + 1, 0);
+
+ return n;
+}
+
void
x_print_expansions(int nwords, char *const *words, int is_command)
{
diff --git a/edit.h b/edit.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.h,v 1.12 2018/06/18 17:03:58 millert Exp $ */
+/* $OpenBSD: edit.h,v 1.13 2023/06/21 22:22:08 millert Exp $ */
/* NAME:
* edit.h - globals for edit modes
@@ -16,6 +16,10 @@
#define BEL 0x07
+#undef CTRL
+#define CTRL(x) ((x) == '?' ? 0x7F : (x) & 0x1F) /* ASCII */
+#define UNCTRL(x) ((x) == 0x7F ? '?' : (x) | 0x40) /* ASCII */
+
/* tty driver characters we are interested in */
typedef struct {
int erase;
diff --git a/emacs.c b/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.89 2021/10/09 21:38:00 halex Exp $ */
+/* $OpenBSD: emacs.c,v 1.90 2023/06/21 22:22:08 millert Exp $ */
/*
* Emacs-like command line editing and history
@@ -40,10 +40,6 @@
static Area aedit;
#define AEDIT &aedit /* area for kill ring and macro defns */
-#undef CTRL
-#define CTRL(x) ((x) == '?' ? 0x7F : (x) & 0x1F) /* ASCII */
-#define UNCTRL(x) ((x) == 0x7F ? '?' : (x) | 0x40) /* ASCII */
-
/* values returned by keyboard functions */
#define KSTD 0
#define KEOL 1 /* ^M, ^J */
diff --git a/eval.c b/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.66 2020/09/13 15:39:09 tb Exp $ */
+/* $OpenBSD: eval.c,v 1.67 2023/05/24 14:20:33 millert Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -8,6 +8,7 @@
#include <ctype.h>
#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
@@ -909,7 +910,7 @@ comsub(Expand *xp, char *cp)
SHF_MAPHI|SHF_CLEXEC);
if (shf == NULL)
warningf(!Flag(FTALKING),
- "%s: cannot open $(<) input", name);
+ "%s: %s", name, strerror(errno));
xp->split = 0; /* no waitlast() */
} else {
int ofd1, pv[2];
diff --git a/exec.c b/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.76 2022/10/10 14:57:48 kn Exp $ */
+/* $OpenBSD: exec.c,v 1.77 2023/06/21 22:22:08 millert Exp $ */
/*
* execute command tree
@@ -1340,33 +1340,6 @@ pr_menu(char *const *ap)
return n;
}
-/* XXX: horrible kludge to fit within the framework */
-
-static char *plain_fmt_entry(void *arg, int i, char *buf, int buflen);
-
-static char *
-plain_fmt_entry(void *arg, int i, char *buf, int buflen)
-{
- shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]);
- return buf;
-}
-
-int
-pr_list(char *const *ap)
-{
- char *const *pp;
- int nwidth;
- int i, n;
-
- for (n = 0, nwidth = 0, pp = ap; *pp; n++, pp++) {
- i = strlen(*pp);
- nwidth = (i > nwidth) ? i : nwidth;
- }
- print_columns(shl_out, n, plain_fmt_entry, (void *) ap, nwidth + 1, 0);
-
- return n;
-}
-
/*
* [[ ... ]] evaluation routines
*/
diff --git a/ksh.1 b/ksh.1
@@ -1,8 +1,8 @@
-.\" $OpenBSD: ksh.1,v 1.218 2022/12/26 17:45:27 jmc Exp $
+.\" $OpenBSD: ksh.1,v 1.219 2023/06/10 07:24:21 op Exp $
.\"
.\" Public Domain
.\"
-.Dd $Mdocdate: December 26 2022 $
+.Dd $Mdocdate: June 10 2023 $
.Dt KSH 1
.Os
.Sh NAME
@@ -2569,20 +2569,6 @@ in non-POSIX mode:
alias a='for ' i='j'
a i in 1 2; do echo i=$i j=$j; done
.Ed
-.It
-.Ic test .
-In POSIX mode, the expression
-.Sq Fl t
-(preceded by some number of
-.Sq \&!
-arguments) is always true as it is a non-zero length string;
-in non-POSIX mode, it tests if file descriptor 1 is a
-.Xr tty 4
-(i.e. the
-.Ar fd
-argument to the
-.Fl t
-test may be left out and defaults to 1).
.El
.Ss Strict Bourne shell mode
When the
@@ -3857,18 +3843,12 @@ socket.
.It Fl s Ar file
.Ar file
is not empty.
-.It Fl t Op Ar fd
+.It Fl t Ar fd
File descriptor
.Ar fd
is a
.Xr tty 4
device.
-If the
-.Ic posix
-option is not set,
-.Ar fd
-may be left out, in which case it is taken to be 1 (the behaviour differs due
-to the special POSIX rules described above).
.It Fl u Ar file
.Ar file Ns 's
mode has the setuid bit set.
diff --git a/main.c b/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.99 2023/02/08 17:22:10 kn Exp $ */
+/* $OpenBSD: main.c,v 1.100 2023/07/23 23:42:03 kn Exp $ */
/*
* startup, main loop, environments and error handling
@@ -88,7 +88,11 @@ static const char *initcoms [] = {
"typeset", "-x", "SHELL", "PATH", "HOME", "PWD", "OLDPWD", NULL,
"typeset", "-ir", "PPID", NULL,
"typeset", "-i", "OPTIND=1", NULL,
+#ifndef SMALL
"eval", "typeset -i RANDOM MAILCHECK=\"${MAILCHECK-600}\" SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
+#else
+ "eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
+#endif /* SMALL */
"alias",
/* Standard ksh aliases */
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
@@ -619,7 +623,9 @@ shell(Source *volatile s, volatile int toplevel)
if (interactive) {
got_sigwinch = 1;
j_notify();
+#ifndef SMALL
mcheck();
+#endif /* SMALL */
set_prompt(PS1);
}
diff --git a/sh.1 b/sh.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sh.1,v 1.156 2022/12/19 08:19:50 sdk Exp $
+.\" $OpenBSD: sh.1,v 1.157 2023/05/13 18:34:49 jmc Exp $
.\"
.\" Copyright (c) 2015 Jason McIntyre <jmc@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 19 2022 $
+.Dd $Mdocdate: May 13 2023 $
.Dt SH 1
.Os
.Sh NAME
@@ -2108,7 +2108,7 @@ on
.Ox
is:
.Bd -literal -offset 2n
-/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin
+/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin
.Ed
.It Ev POSIXLY_CORRECT
Enable POSIX mode
diff --git a/sh.h b/sh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh.h,v 1.76 2020/07/07 10:33:58 jca Exp $ */
+/* $OpenBSD: sh.h,v 1.77 2023/06/21 22:22:08 millert Exp $ */
/*
* Public Domain Bourne/Korn shell
@@ -441,7 +441,6 @@ void flushcom(int);
char * search(const char *, const char *, int, int *);
int search_access(const char *, int, int *);
int pr_menu(char *const *);
-int pr_list(char *const *);
/* expr.c */
int evaluate(const char *, int64_t *, int, bool);
int v_evaluate(struct tbl *, const char *, volatile int, bool);
diff --git a/var.c b/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.72 2021/03/05 15:22:03 zhuk Exp $ */
+/* $OpenBSD: var.c,v 1.73 2023/07/23 23:42:03 kn Exp $ */
#include <sys/stat.h>
#include <sys/time.h>
@@ -117,9 +117,11 @@ initvar(void)
{ "HISTSIZE", V_HISTSIZE },
{ "EDITOR", V_EDITOR },
{ "VISUAL", V_VISUAL },
+#ifndef SMALL
{ "MAIL", V_MAIL },
{ "MAILCHECK", V_MAILCHECK },
{ "MAILPATH", V_MAILPATH },
+#endif /* SMALL */
{ "RANDOM", V_RANDOM },
{ "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT },
@@ -1038,6 +1040,7 @@ setspec(struct tbl *vp)
x_cols = l;
}
break;
+#ifndef SMALL
case V_MAIL:
mbset(str_val(vp));
break;
@@ -1049,6 +1052,7 @@ setspec(struct tbl *vp)
mcset(intval(vp));
vp->flag |= SPECIAL;
break;
+#endif /* SMALL */
case V_RANDOM:
vp->flag &= ~SPECIAL;
srand_deterministic((unsigned int)intval(vp));
@@ -1108,17 +1112,21 @@ unsetspec(struct tbl *vp)
afree(tmpdir, APERM);
tmpdir = NULL;
break;
+#ifndef SMALL
case V_MAIL:
mbset(NULL);
break;
case V_MAILPATH:
mpset(NULL);
break;
+#endif /* SMALL */
case V_HISTCONTROL:
sethistcontrol(NULL);
break;
case V_LINENO:
+#ifndef SMALL
case V_MAILCHECK: /* at&t ksh leaves previous value in place */
+#endif /* SMALL */
case V_RANDOM:
case V_SECONDS:
case V_TMOUT: /* at&t ksh leaves previous value in place */