bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFE: request for quotes as grouping operators to work in brackets as


From: Pierre Gaston
Subject: Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere.
Date: Sat, 18 Sep 2010 22:06:10 +0300

On Sat, Sep 18, 2010 at 9:45 PM, Linda Walsh <bash@tlinx.org> wrote:
>
> I use == to compare constant strings.
> When you compare 'test' with t??t, the globbing operator has precedence and
> attempts to match the string t??t against test.  If it can match the glob
> pattern against the intput 'test', then it substitutes in the literal string
> 'test' and that result is passed the the '==' operator, which returns true.
>
> IT isn't the == operator that turns t??t into something that can match
> 'test'.
> t??t will match 'test' in an 'echo' statement or in an 'ls' statement if
> there is a file by that name in your current directory.

You are confusing pattern matching an pathname generation.
pathname generation doesn't occur inside [[  ]], like it doesn't in a case.

mkdir bar; cd bar # ie go into a directory with no file
[ foo = f* ] && echo match   # doesn't print anything [ doesn't do
pattern matching
[[ foo = f* ]] && echo match # matches because [[ does pattern matching

on the contrary:
touch bar buz
[ foo =  b* ] # errors because bash tries to run [ foo = bar buz ]
[[ foo = b * ]] # no error pathname generation doesn't occur inside [[ ]]

you can also use set -x to see this



reply via email to

[Prev in Thread] Current Thread [Next in Thread]