[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RFE: allow double quotes to group multi-words & be treated as 1 arg, w/D
From: |
Linda Walsh |
Subject: |
RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~ |
Date: |
Wed, 04 Aug 2010 01:06:16 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
On 8/1/2010 8:11 PM, Chris F.A. Johnson wrote:
> On Sun, 1 Aug 2010, Linda Walsh wrote:
>
>> I have:
>>
>> w="/home/law/bin/package: line 5: type: xx: not found"
>>
>> The =~ operator is suppose to use the RH Expr as a ext.-regex.
>>
>> So why doesn't this match and print "not found"?
>>
>> if [[ $w =~ ".*not found.*" ]]; then echo "not found"; fi
>>
>> It prints nothing. Seems like such a basic concept. Sorry, this newbie
>> needs help on such trivial matters. :-(
>
> When quoted, the right-hand argument is matched as a string, not an
> expression.
>
So that's how it is...
Aren't single quotes reserved for making things literal, while
double quotes are used for grouping, yet interpreting what is between them
(expansions and such).
Is there a reason "RH =~" was made inconsistent regarding this practice?
I might note: the man page makes no reference to such heinous behavior, leading
one
me to think I'd use single quotes if I didn't want the contents to be 'active'
Though
to tell the truth. Technically, it says:
An additional binary operator, =~, is available, with the same
precedence as == and !=. When it is used, the string to the
right of the operator is considered an extended regular expres-
sion and matched accordingly (as in regex(3)).
I don't see anything about quotes making the =~ operator behave like
the == operator. I'm not sure I see the usefulness in that.
If there is, then is it necessary to reserving both single and double quotes
to make "=~" behave like "=="?
Therefore:
RFE:
Please make double quotes a grouping operator to group multiple words (as in
separated by spaces)
together -- even if it is on the RH of =~. Let single quotes be the 'do not
interpret this'
signifier. Otherwise there's no nice way to group together patterns that have
spaces in them.
Inserting '\' before every space isn't my idea of nice: Ick!
p.s. -- why do you want to have =~ behave like ==? I.e. why these special
cases to
deactivate regex? Isn't the whole point of =~ to use the RH as an regex? Why
have
syntax to disable it?
I.E -- please consider another possibility:
Using double quotes would first do a variable substitution pass, while
using
single quotes would not -- but use the literal string as a regex.
Why throw away useful functionality of quotes with a new operator?
- basic pattern match Question..."newbie" doesn't understand (!@#$@$), Linda Walsh, 2010/08/01
- Re: basic pattern match Question..."newbie" doesn't understand (!@#$@$), Chris F.A. Johnson, 2010/08/01
- RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~,
Linda Walsh <=
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Davide Brini, 2010/08/04
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Linda Walsh, 2010/08/04
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Andreas Schwab, 2010/08/04
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Greg Wooledge, 2010/08/04
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Chet Ramey, 2010/08/05
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Linda Walsh, 2010/08/05
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Andreas Schwab, 2010/08/05
- Re: RFE: allow double quotes to group multi-words & be treated as 1 arg, w/DQ's stripped off -- including RH =~, Chet Ramey, 2010/08/05
- Message not available
- Re: RFE: allow double quotes to group multi-words & be treated as?1?arg, w/DQ's stripped off -- including RH =~, clemens fischer, 2010/08/06
- Message not available
- Message not available
- Re: RFE: allow double quotes to group multi-words & be treated?as?1?arg, w/DQ's stripped off -- including RH =~, clemens fischer, 2010/08/09