[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interpretation of escapes in expansions in pattern matching contexts
From: |
Chet Ramey |
Subject: |
Re: Interpretation of escapes in expansions in pattern matching contexts |
Date: |
Sat, 06 Apr 2013 22:17:58 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 |
On 4/6/13 9:59 PM, Chris F.A. Johnson wrote:
> In bash, the expansion differs when in [[ ... ]]:
>
> $ x=\\x; if [[ x == $x ]]; then echo yes; else echo no; fi
> yes
> $ x=\\x; if [ x == $x ]; then echo yes; else echo no; fi
> no
OK. The [[ conditional command does pattern matching. The [ (test)
command does string comparison. $x expands to `\x' in both cases.
>
> But not in ksh93:
I'm going to assume ksh93 dequotes the variable. I don't know why.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/