From daa208e90763d304dc1d554a834d0066e0b9937c Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Tue, 10 Aug 2021 09:19:32 +0100
Subject: [PATCH] 49269: Fix "[ ! -o ]".
This should detect "-o" as non-empty string; "-a" was alrady working.
Update the test.
---
ChangeLog | 6 ++++++
Src/parse.c | 2 +-
Test/C02cond.ztst | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4690121fc..b7ba668f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-08-10 Peter Stephenson
+
+ * 49269: Src/parse.c, Test/C02cond.ztst: "[ ! -o ]" should
+ detect "-o" as a non-empty string and return status 1. Update
+ test to reflect this.
+
2021-07-30 dana
* github #77: Stavros Ntentos: Completion/X/Command/_sublimetext:
diff --git a/Src/parse.c b/Src/parse.c
index b09c7989a..be26112a5 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2509,7 +2509,7 @@ par_cond_2(void)
* In "test" compatibility mode, "! -a ..." and "! -o ..."
* are treated as "[string] [and] ..." and "[string] [or] ...".
*/
- if (!(n_testargs > 1 && (check_cond(*testargs, "a") ||
+ if (!(n_testargs > 2 && (check_cond(*testargs, "a") ||
check_cond(*testargs, "o"))))
{
condlex();
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 5b105b2a0..4366b4142 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -380,7 +380,7 @@ F:scenario if you encounter it.
>0
>0
>1
->0
+>1
>0
>0
>1