[Top][All Lists]

[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: Gecko/20100228 Lightning/0.9 Thunderbird/ Mnenhy/

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 
me to think I'd use single quotes if I didn't want the contents to be 'active'  
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 "=="?

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 
syntax to disable it?

I.E  -- please consider another possibility:
        Using double quotes would first do a variable substitution pass, while 
single quotes would not -- but use the literal string as a regex.

Why throw away useful functionality of quotes with a new operator?

reply via email to

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