[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
- RFE: request for quotes as grouping operators to work in brackets as elsewhere., Linda Walsh, 2010/09/17
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Jan Schampera, 2010/09/17
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Chet Ramey, 2010/09/17
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Linda Walsh, 2010/09/18
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere.,
Pierre Gaston <=
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Chet Ramey, 2010/09/18
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Linda Walsh, 2010/09/18
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Chet Ramey, 2010/09/18
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Linda Walsh, 2010/09/18
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Pierre Gaston, 2010/09/19
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Linda Walsh, 2010/09/20
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Pierre Gaston, 2010/09/20
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Linda Walsh, 2010/09/21
- Re: RFE: request for quotes as grouping operators to work in brackets as elsewhere., Greg Wooledge, 2010/09/21
- Re: RFE: request for grouping mechanism to work in double brackets where otherewise illegal, Linda Walsh, 2010/09/22