summaryrefslogtreecommitdiff
path: root/system/pdksh/patches/112_OpenBSD-test.patch
diff options
context:
space:
mode:
Diffstat (limited to 'system/pdksh/patches/112_OpenBSD-test.patch')
-rw-r--r--system/pdksh/patches/112_OpenBSD-test.patch58
1 files changed, 58 insertions, 0 deletions
diff --git a/system/pdksh/patches/112_OpenBSD-test.patch b/system/pdksh/patches/112_OpenBSD-test.patch
new file mode 100644
index 0000000000..7058a2dac8
--- /dev/null
+++ b/system/pdksh/patches/112_OpenBSD-test.patch
@@ -0,0 +1,58 @@
+From OpenBSD:
+
+2009-03-01 21:11 otto
+
+ * c_test.c (1.18): Fix PR #723: test(1) operator precedence
+ inconsistent with POSIX Make sure ksh builtin test and test(1) do
+ not differ. From Christiano Farina Haesbaert. ok miod@
+
+
+Index: pdksh-5.2.14/c_test.c
+===================================================================
+--- pdksh-5.2.14.orig/c_test.c 2009-09-19 11:22:39.000000000 +0200
++++ pdksh-5.2.14/c_test.c 2009-09-19 12:03:25.000000000 +0200
+@@ -551,15 +551,23 @@
+ }
+ return res;
+ }
+- if ((op = (Test_op) (*te->isa)(te, TM_UNOP))) {
+- /* unary expression */
+- opnd1 = (*te->getopnd)(te, op, do_eval);
+- if (!opnd1) {
+- (*te->error)(te, -1, "missing argument");
+- return 0;
+- }
++ /*
++ * Binary should have precedence over unary in this case
++ * so that something like test \( -f = -f \) is accepted
++ */
++ if ((te->flags & TEF_DBRACKET) || (&te->pos.wp[1] < te->wp_end &&
++ !test_isop(te, TM_BINOP, te->pos.wp[1]))) {
++ if ((op = (Test_op) (*te->isa)(te, TM_UNOP))) {
++ /* unary expression */
++ opnd1 = (*te->getopnd)(te, op, do_eval);
++ if (!opnd1) {
++ (*te->error)(te, -1, "missing argument");
++ return 0;
++ }
+
+- return (*te->eval)(te, op, opnd1, (const char *) 0, do_eval);
++ return (*te->eval)(te, op, opnd1, (const char *) 0,
++ do_eval);
++ }
+ }
+ opnd1 = (*te->getopnd)(te, TO_NONOP, do_eval);
+ if (!opnd1) {
+Index: pdksh-5.2.14/tests/debian-112.t
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ pdksh-5.2.14/tests/debian-112.t 2009-09-19 12:06:33.000000000 +0200
+@@ -0,0 +1,8 @@
++name: debian-112-1
++description:
++ Check test operator precedence
++stdin:
++ test \( -f = -f \) && echo OK
++expected-stdout:
++ OK
++---