summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2019-06-19 18:18:22 +0000
committermillert <millert@openbsd.org>2019-06-19 18:18:22 +0000
commit5b199efb7af14d11623972ca1c5b8be5db516d8f (patch)
treef6559a8d0289c2a3bdf1232de5cadb3d811667ff
parentthe pledge STATLIE code is no longer needed, as discussed with beck. (diff)
downloadwireguard-openbsd-5b199efb7af14d11623972ca1c5b8be5db516d8f.tar.xz
wireguard-openbsd-5b199efb7af14d11623972ca1c5b8be5db516d8f.zip
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@
-rw-r--r--bin/ksh/c_test.c9
-rw-r--r--bin/ksh/ksh.117
2 files changed, 14 insertions, 12 deletions
diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c
index 911f2bf0404..8422c0936a4 100644
--- a/bin/ksh/c_test.c
+++ b/bin/ksh/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 ::= <any thing>
*/
@@ -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/bin/ksh/ksh.1 b/bin/ksh/ksh.1
index 44fad1e4106..d4204da4788 100644
--- a/bin/ksh/ksh.1
+++ b/bin/ksh/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