[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ksh style [[ conditional does not match patterns
From: |
Michael Wardle |
Subject: |
ksh style [[ conditional does not match patterns |
Date: |
Fri, 09 Dec 2005 13:22:38 +1100 |
User-agent: |
Thunderbird 1.5 (Windows/20051025) |
In the SHELL GRAMMAR section of the bash man page, the [[ expression ]]
syntax is described:
When the == and != operators are used, the string to the right of the
operator is
considered a pattern and matched according to the rules described below
under Pattern Matching.
The Pattern Matching subsection describes the familiar file name
globbing syntax:
* Matches any string, including the null string.
? Matches any single character.
etc.
Yet when I attempt a simple match, it doesn't work:
bash-3.00$ [[ "foo" == "foo" ]]
bash-3.00$ echo $?
0
bash-3.00$ [[ "foo" == "fo?" ]]
bash-3.00$ echo $?
1
(I expect the second command to return 0 exit status as well, since the
question mark should match the single "o" character at position 3 in "foo".)
Am I doing something wrong?
- ksh style [[ conditional does not match patterns,
Michael Wardle <=