1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Backport ksh93v- bugfix for [[ 1<2 ]] (#380)

Strings compared in [[ with the > and < operators should be compared
lexically. This does not work when the strings are single digits, as
the parser interprets it as a syntax error:
   $ [[ 10<2 ]]   # 10 lexically sorts before 2
   $ echo $?
   0
   $ [[ 1<2 ]]
   /usr/bin/ksh: syntax error: `<' unexpected
   $ echo $?
   3

src/cmd/ksh93/sh/lex.c:
- Don't interpret numbers next to > and < as a redirection while
  inside of [[. This bugfix was backported from ksh93v- 2014-06-25.

src/cmd/ksh93/tests/bracket.sh:
- Add regression tests for the > and < operators.
This commit is contained in:
Johnothan King 2021-12-16 18:24:56 -08:00 committed by Martijn Dekker
parent e67df29c07
commit 85199ab351
3 changed files with 58 additions and 1 deletions

View file

@ -1264,7 +1264,7 @@ breakloop:
{
/* check for numbered redirection */
n = state[0];
if((c=='<' || c=='>') && isadigit(n))
if(!lp->lex.intest && (c=='<' || c=='>') && isadigit(n))
{
c = sh_lex(lp);
lp->digits = (n-'0');