Michael Wardle wrote:
> 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?
You didn't read far enough in the man page. Later on in the description
of `[[' is the following:
Any part of the pattern may be
quoted to force it to be matched as a string.
Quoting the pattern forces string comparison.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live Strong.
Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://cnswww.cns.cwru.edu/~chet/
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash