From b8decd63900dcc3563145d354f57ae04b06846b4 Mon Sep 17 00:00:00 2001 From: Brian Callahan Date: Thu, 20 Jun 2019 06:41:34 -0400 Subject: [PATCH] CVSROOT: /cvs Module name: src Changes by: millert@cvs.openbsd.org 2019/06/19 12:18:22 Modified files: bin/ksh : c_test.c ksh.1 Log message: Allow string greater/less than than operators to work with test aka [. Previously they were only recognized in [[ ... ]] expressions. This changes sh/ksh to be consistent with test(1) as well as shells like bash and dash. OK jca@ jmc@ --- CVS/Entries | 66 ++++++++++++++++++++++++++--------------------------- c_test.c | 9 +++----- ksh.1 | 17 +++++++++----- sh.1 | 10 +++++--- 4 files changed, 54 insertions(+), 48 deletions(-) diff --git a/CVS/Entries b/CVS/Entries index 75efb1d..52cad17 100644 --- a/CVS/Entries +++ b/CVS/Entries @@ -1,46 +1,46 @@ /config.h/1.19/Tue Jan 16 02:21:56 2018// /io.c/1.36/Fri Jun 1 19:10:08 2018// /tty.c/1.17/Fri Jun 1 19:10:08 2018// -/c_test.c/1.25/Sun Sep 23 17:58:57 2018// /exec.c/1.73/Sun Sep 23 17:58:57 2018// /var.c/1.70/Sun Sep 23 17:59:17 2018// /edit.c/1.67/Result of merge// /history.c/1.81/Result of merge// /misc.c/1.72/Result of merge// -/CONTRIBUTORS/1.11/Sat Apr 6 14:12:34 2019// -/LEGAL/1.2/Sat Apr 6 14:12:27 2019// -/Makefile/1.39/Sat Apr 6 14:12:34 2019// -/NOTES/1.16/Sat Apr 6 14:12:27 2019// -/PROJECTS/1.9/Sat Apr 6 14:12:27 2019// -/README/1.16/Sat Apr 6 14:12:34 2019// -/alloc.c/1.19/Sat Apr 6 14:12:27 2019// -/c_ksh.c/1.61/Sat Apr 6 14:12:27 2019// -/c_sh.c/1.63/Sat Apr 6 14:12:27 2019// -/c_test.h/1.4/Sat Apr 6 14:12:27 2019// -/c_ulimit.c/1.28/Sat Apr 6 14:12:27 2019// -/edit.h/1.12/Sat Apr 6 14:12:27 2019// /emacs.c/1.86/Result of merge// /eval.c/1.64/Result of merge// -/expand.h/1.15/Sat Apr 6 14:12:27 2019// -/expr.c/1.34/Sat Apr 6 14:12:34 2019// -/jobs.c/1.60/Sat Apr 6 14:12:27 2019// -/ksh.1/1.203/Sat Apr 6 14:12:34 2019// -/lex.c/1.78/Sat Apr 6 14:12:27 2019// -/lex.h/1.21/Sat Apr 6 14:12:27 2019// -/mail.c/1.27/Sat Apr 6 14:12:34 2019// /main.c/1.97/Result of merge// -/path.c/1.22/Sat Apr 6 14:12:27 2019// -/sh.1/1.151/Sat Apr 6 14:12:27 2019// /sh.h/1.75/Result of merge// -/shf.c/1.33/Sat Apr 6 14:12:27 2019// -/shf.h/1.8/Sat Apr 6 14:12:27 2019// -/syn.c/1.39/Sat Apr 6 14:12:27 2019// -/table.c/1.25/Sat Apr 6 14:12:27 2019// -/table.h/1.15/Sat Apr 6 14:12:27 2019// -/trap.c/1.33/Sat Apr 6 14:12:27 2019// -/tree.c/1.34/Sat Apr 6 14:12:27 2019// -/tree.h/1.12/Sat Apr 6 14:12:27 2019// -/tty.h/1.6/Sat Apr 6 14:12:27 2019// -/version.c/1.12/Sat Apr 6 14:12:27 2019// -/vi.c/1.56/Sat Apr 6 14:12:27 2019// +/CONTRIBUTORS/1.11/Thu Jun 20 10:34:00 2019// +/LEGAL/1.2/Thu Jun 20 10:34:00 2019// +/Makefile/1.39/Thu Jun 20 10:34:07 2019// +/NOTES/1.16/Thu Jun 20 10:34:00 2019// +/PROJECTS/1.9/Thu Jun 20 10:34:00 2019// +/README/1.16/Thu Jun 20 10:34:07 2019// +/alloc.c/1.19/Thu Jun 20 10:34:00 2019// +/c_ksh.c/1.61/Thu Jun 20 10:34:00 2019// +/c_sh.c/1.63/Thu Jun 20 10:34:00 2019// +/c_test.c/1.26/Result of merge// +/c_test.h/1.4/Thu Jun 20 10:34:00 2019// +/c_ulimit.c/1.28/Thu Jun 20 10:34:00 2019// +/edit.h/1.12/Thu Jun 20 10:34:00 2019// +/expand.h/1.15/Thu Jun 20 10:34:00 2019// +/expr.c/1.34/Thu Jun 20 10:34:00 2019// +/jobs.c/1.60/Thu Jun 20 10:34:00 2019// +/ksh.1/1.204/Thu Jun 20 10:34:07 2019// +/lex.c/1.78/Thu Jun 20 10:34:00 2019// +/lex.h/1.21/Thu Jun 20 10:34:00 2019// +/mail.c/1.27/Thu Jun 20 10:34:00 2019// +/path.c/1.22/Thu Jun 20 10:34:00 2019// +/sh.1/1.152/Thu Jun 20 10:34:07 2019// +/shf.c/1.33/Thu Jun 20 10:34:00 2019// +/shf.h/1.8/Thu Jun 20 10:34:00 2019// +/syn.c/1.39/Thu Jun 20 10:34:00 2019// +/table.c/1.25/Thu Jun 20 10:34:00 2019// +/table.h/1.15/Thu Jun 20 10:34:00 2019// +/trap.c/1.33/Thu Jun 20 10:34:00 2019// +/tree.c/1.34/Thu Jun 20 10:34:00 2019// +/tree.h/1.12/Thu Jun 20 10:34:00 2019// +/tty.h/1.6/Thu Jun 20 10:34:00 2019// +/version.c/1.12/Thu Jun 20 10:34:00 2019// +/vi.c/1.56/Thu Jun 20 10:34:00 2019// D diff --git a/c_test.c b/c_test.c index 21f2d32..6d22b72 100644 --- a/c_test.c +++ b/c_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_test.c,v 1.25 2018/04/09 17:53:36 tobias Exp $ */ +/* $OpenBSD: c_test.c,v 1.26 2019/06/19 18:18:22 millert Exp $ */ /* * test(1); version 7-like -- author Erik Baalbergen @@ -32,8 +32,7 @@ "-L"|"-h"|"-S"|"-H"; binary-operator ::= "="|"=="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"| - "-nt"|"-ot"|"-ef"| - "<"|">" # rules used for [[ .. ]] expressions + "-nt"|"-ot"|"-ef"|"<"|">" ; operand ::= */ @@ -195,9 +194,7 @@ test_isop(Test_env *te, Test_meta meta, const char *s) sc1 = s[1]; for (; otab->op_text[0]; otab++) if (sc1 == otab->op_text[1] && - strcmp(s, otab->op_text) == 0 && - ((te->flags & TEF_DBRACKET) || - (otab->op_num != TO_STLT && otab->op_num != TO_STGT))) + strcmp(s, otab->op_text) == 0) return otab->op_num; } return TO_NONOP; diff --git a/ksh.1 b/ksh.1 index 44fad1e..d4204da 100644 --- a/ksh.1 +++ b/ksh.1 @@ -1,8 +1,8 @@ -.\" $OpenBSD: ksh.1,v 1.203 2019/04/03 14:55:12 jca Exp $ +.\" $OpenBSD: ksh.1,v 1.204 2019/06/19 18:18:22 millert Exp $ .\" .\" Public Domain .\" -.Dd $Mdocdate: April 3 2019 $ +.Dd $Mdocdate: June 19 2019 $ .Dt KSH 1 .Os .Sh NAME @@ -750,12 +750,13 @@ expressions are patterns (e.g. the comparison .Ic [[ foobar = f*r ]] succeeds). .It -There are two additional binary operators, +The .Ql < and -.Ql > , -which return true if their first string operand is less than, or greater than, -their second string operand, respectively. +.Ql > +binary operators do not need to be quoted with the +.Ql \e +character. .It The single argument form of .Ic test , @@ -3890,6 +3891,10 @@ Strings are equal. Strings are equal. .It Ar string No != Ar string Strings are not equal. +.It Ar string No > Ar string +Strings compare greater than based on the ASCII value of their characters. +.It Ar string No < Ar string +Strings compare less than based on the ASCII value of their characters. .It Ar number Fl eq Ar number Numbers compare equal. .It Ar number Fl ne Ar number diff --git a/sh.1 b/sh.1 index 4f53723..8328548 100644 --- a/sh.1 +++ b/sh.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sh.1,v 1.151 2018/12/16 13:08:35 schwarze Exp $ +.\" $OpenBSD: sh.1,v 1.152 2019/05/22 15:23:23 schwarze Exp $ .\" .\" Copyright (c) 2015 Jason McIntyre .\" @@ -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 16 2018 $ +.Dd $Mdocdate: May 22 2019 $ .Dt SH 1 .Os .Sh NAME @@ -866,7 +866,11 @@ it keeps a record of commands run in a either internally in memory or in a file, as determined by .Dv HISTFILE . -The command line and all the commands in command history +When +.Cm vi +command line editing mode is enabled +.Pq set -o vi , +the command line and all the commands in command history can be edited using commands similar to those of .Xr vi 1 . .Pp