mirror of
https://git.code.sf.net/p/zsh/code
synced 2026-04-18 06:53:35 -04:00
54103: support > and < comparisons via the test builtin
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2025-11-24 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 54103: Src/builtin.c, Src/parse.c, Test/C02cond.ztst:
|
||||
support > and < comparisons via the test builtin
|
||||
|
||||
* 54094: Completion/Unix/Command/_base64,
|
||||
Completion/Unix/Command/_basename, Completion/Unix/Command/_cat,
|
||||
Completion/Unix/Command/_chmod, Completion/Unix/Command/_chown,
|
||||
|
||||
@@ -7243,6 +7243,10 @@ testlex(void)
|
||||
tok = INPAR;
|
||||
else if (!strcmp(*testargs, ")"))
|
||||
tok = OUTPAR;
|
||||
else if (!strcmp(*testargs, "<"))
|
||||
tok = INANG;
|
||||
else if (!strcmp(*testargs, ">"))
|
||||
tok = OUTANG;
|
||||
else
|
||||
tok = STRING;
|
||||
testargs++;
|
||||
|
||||
@@ -2495,6 +2495,8 @@ par_cond_2(void)
|
||||
/* three arguments: if the second argument is a binary operator, *
|
||||
* perform that binary test on the first and the third argument */
|
||||
if (!strcmp(*testargs, "=") ||
|
||||
!strcmp(*testargs, "<") ||
|
||||
!strcmp(*testargs, ">") ||
|
||||
!strcmp(*testargs, "==") ||
|
||||
!strcmp(*testargs, "!=") ||
|
||||
(IS_DASH(**testargs) && get_cond_num(*testargs + 1) >= 0)) {
|
||||
@@ -2661,6 +2663,12 @@ par_cond_triple(char *a, char *b, char *c)
|
||||
ecstr(a);
|
||||
ecstr(c);
|
||||
ecadd(ecnpats++);
|
||||
} else if ((t0 = (b[0] == '>' || b[0] == Outang) ||
|
||||
b[0] == '<' || b[0] == Inang) && !b[1]) {
|
||||
ecadd(WCB_COND(t0 ? COND_STRGTR : COND_STRLT, 0));
|
||||
ecstr(a);
|
||||
ecstr(c);
|
||||
ecadd(ecnpats++);
|
||||
} else if ((b[0] == Equals || b[0] == '=') &&
|
||||
(b[1] == Equals || b[1] == '=') && !b[2]) {
|
||||
ecadd(WCB_COND(COND_STRDEQ, 0));
|
||||
|
||||
@@ -214,6 +214,12 @@ F:scenario if you encounter it.
|
||||
[ '' != bar -a '' = '' ]
|
||||
0:strings with `[' builtin
|
||||
|
||||
[ zzd '>' zzb -a e '<' x ]
|
||||
0:string comparisons with `[' builtin
|
||||
|
||||
[ -o \> -a ]
|
||||
0:string comparison with strings that look like operators
|
||||
|
||||
[ `echo 0` -lt `echo 1` ]
|
||||
0:substitution in `[' builtin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user