bug-bash
[Top][All Lists]
Advanced

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

Re: [DOC] Incomplete explanation about the regex =~ operator


From: Chet Ramey
Subject: Re: [DOC] Incomplete explanation about the regex =~ operator
Date: Thu, 17 Jan 2019 10:46:16 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 1/17/19 1:53 AM, kevin wrote:

> 
>    Since *[[* isn't a normal command (like [ is), but a /shell
>    keyword/, *it has special magical powers*. *It parses its arguments
>    before they are expanded by Bash and does the expansion itself*,
>    taking the result as a single argument, even if that result contains
>    whitespace. (In other words, [[ does not allow word-splitting of its
>    arguments.) /However/, be aware that simple strings still have to be
>    quoted properly. [[ treats a space outside of quotes as an argument
>    separator, just like Bash normally would.
> 
> Unfortunately, there is no example that shows how *[[* differs from the
> usual shell operation. I know that the documentation does not indicate the
> particular property of "[[" (features)

Sure it does. The expansions and parsing are covered in the man page
description of `[['. For instance:

"Word  splitting  and pathname expansion are not performed on the
 words between the [[ and  ]];  tilde  expansion,  parameter  and
 variable  expansion, arithmetic expansion, command substitution,
 process substitution, and quote removal are  performed."

The parsing and expansions that `[[' performs are specified completely.
They are different from the set of word expansions a simple command
like `[' undergoes before it is executed.


, and there has been an adjustment
> based on the operator "==" concerning "=~" but I still do not understand
> why we could not have used the normal shell rules. In your example, a user
> may use single quotes to escape the special meaning of the $ sign "abc'$'".

What are those "normal shell rules?" And how would you have applied them
to specify something that was unspecified before? This discussion began in
mid-2006, maybe go back and look at the bug-bash archives to see what
people were reporting?

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

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