A NOTE has been added to this issue. 
====================================================================== 
http://austingroupbugs.net/view.php?id=375 
====================================================================== 
Reported By:                dwheeler
Assigned To:                ajosey
====================================================================== 
Project:                    1003.1(2008)/Issue 7
Issue ID:                   375
Category:                   Shell and Utilities
Type:                       Enhancement Request
Severity:                   Objection
Priority:                   normal
Status:                     Under Review
Name:                       David A. Wheeler 
Organization:                
User Reference:              
Section:                    test 
Page Number:                3224-3225 
Line Number:                107503-107513 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2011-02-07 18:34 UTC
Last Modified:              2016-09-20 20:34 UTC
====================================================================== 
Summary:                    Extend test/[...] conditionals: ==, <, >, -nt, -ot,
-ef
======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
has duplicate       0000762 Add &quot;==&quot; as synonym for &quot...
related to          0000813 Utility numeric argument syntax require...
====================================================================== 

---------------------------------------------------------------------- 
 (0003384) stephane (reporter) - 2016-09-20 20:34
 http://austingroupbugs.net/view.php?id=375#c3384 
---------------------------------------------------------------------- 
Re: http://austingroupbugs.net/view.php?id=375#c3383

1- about grammar

That doesn't work. For instance the space character is not special in EREs,
yet

[[ $a =~ a b ]]

doesn't work obviously.

The behaviour for the a\ b ERE is unspecified. We may need to acknowledged
somehow that backslash is overloaded as a quoting operator in the shell and
as an escaping operator for EREs.

For instance, is re='a\b'; [[ a =~ $re ]] meant to be treated the same as
[[ a =~ a\b ]] (it's not in bash). And re='a"."b'; [[ a =~ $re ]] vs [[ a
=~ a"."b ]]

See also:

$ bash -c '[[ a =~ & ]]'
bash: -c: line 0: syntax error in conditional expression: unexpected token
`&'
bash: -c: line 0: syntax error near `&'
bash: -c: line 0: `[[ a =~ & ]]'

(same for #, < , >)

IMO, the original [[ =~ ]] implementation (in bash31) which is also the one
of zsh, where shell quoting doesn't make any difference in terms of RE
matching is a lot cleaner and easier to specify (applications just do [[
$var =~ '(..|X)&' ]], make sure the argument to =~ is a normal *shell*
WORD.

Or we could just give up on specifying [[...]] altogether (my preference as
it's broken by design except in zsh IMO as its =/== operator is not an
equality operator and it has hardly any benefit over the "[" command) and
add the =~ operator to "[" like in yash or zsh which would also be
straightforward to specify and unambiguous.

2- about ~

Whether ~ is a ERE operator or not is irrelevant here. The fact that it's
*not* a ERE operator (it is in ksh93 REs though as in [[ a =~ (?K:~(E)a)
]]) makes it even a justification that ~ can be safely expanded. ` is not a
ERE operator either, yet [[ Linux =~ `uname` ]] returns true on Linux with
both ksh93 and bash.

It's just that we need to clarify what expansions are or may be performed
in the argument to =~. Expanding ~ is not very useful because it's only
expanded at the start of the RE, but I can't see why it wouldn't be when
`...`, $param, $((arith)), $(cmd) are.

Also note that in bash the expansion of ~ ends up being quoted from an ERE
point of view, which makes sense as ~ is meant to expand to a path, not a
RE. As in HOME=.; [[ a/a =~ ~/a ]] returns false.

In bash, the same applies to process substitution.

[[ "<:" =~ <(:) ]] returns false (true in ksh93)

Both bash and ksh93 have taken some liberties with the standard inside
[[...]] as that construct was not specified by the standard. It's going to
be hard to come up with a specification that doesn't break either or both.
And if you want to throw zsh in the picture as well, it's going to be more
difficult... or simpler if we only specify [[ a =~ $var ]], that is leave
it unspecified unless the word after =~ is an unquoted variable and the
content of the variable contains a valid ERE. At the moment, that's the
only thing that is portable across bash31, bash32-or-above, zsh and ksh93. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-02-07 18:34 dwheeler       New Issue                                    
2011-02-07 18:34 dwheeler       Status                   New => Under Review 
2011-02-07 18:34 dwheeler       Assigned To               => ajosey          
2011-02-07 18:34 dwheeler       Name                      => David A. Wheeler
2011-02-07 18:34 dwheeler       Section                   => test            
2011-02-07 18:34 dwheeler       Page Number               => 3224-3225       
2011-02-07 18:34 dwheeler       Line Number               => 107503-107513   
2011-02-07 18:49 dwheeler       Note Added: 0000666                          
2011-02-07 20:23 Don Cragun     Interp Status             => ---             
2011-02-07 20:23 Don Cragun     Note Added: 0000667                          
2011-02-07 20:23 Don Cragun     Severity                 Editorial => Objection
2011-02-07 20:23 Don Cragun     Type                     Clarification Requested
=> Enhancement Request
2011-02-07 21:56 dwheeler       Note Added: 0000668                          
2011-02-07 22:20 Don Cragun     Description Updated                          
2011-02-07 22:20 Don Cragun     Desired Action Updated                       
2011-02-07 22:22 Don Cragun     Note Edited: 0000667                         
2011-02-07 22:50 dwheeler       Note Added: 0000669                          
2011-02-07 23:13 eblake         Note Added: 0000670                          
2011-03-08 03:15 dwheeler       Note Added: 0000688                          
2011-04-24 13:16 jsonn          Note Added: 0000754                          
2011-04-24 19:01 dwheeler       Note Added: 0000755                          
2011-04-24 21:48 jsonn          Note Added: 0000756                          
2011-04-25 20:45 dwheeler       Note Added: 0000758                          
2011-04-26 09:25 markh          Note Added: 0000759                          
2011-04-26 09:57 wpollock       Note Added: 0000760                          
2011-04-26 10:36 jsonn          Note Added: 0000761                          
2011-09-22 08:59 ajosey         Note Added: 0000967                          
2011-09-25 00:36 dwheeler       Note Added: 0000974                          
2011-09-25 18:51 gber           Note Added: 0000975                          
2011-09-28 07:09 olof           Issue Monitored: olof                        
2011-11-15 17:26 dwheeler       Note Added: 0001011                          
2011-11-15 19:25 ajosey         File Added: Extendingshellconditionals.pdf      
             
2011-11-15 19:27 ajosey         File Added: Extendingshellconditionals.txt      
             
2011-11-15 19:30 ajosey         Note Added: 0001013                          
2011-11-23 23:49 dwheeler       File Added:
Extendingshellconditionals-2011-11-23.pdf                    
2011-11-23 23:50 dwheeler       File Added:
Extendingshellconditionals-2011-11-23.odt                    
2011-11-23 23:50 dwheeler       File Added:
Extendingshellconditionals-2011-11-23.txt                    
2011-11-23 23:57 dwheeler       Note Added: 0001044                          
2011-11-28 15:50 geoffclare     Note Added: 0001060                          
2011-11-28 15:51 geoffclare     File Added:
Extendingshellconditionals-2011-11-28.odt                    
2011-11-28 15:52 geoffclare     File Added:
Extendingshellconditionals-2011-11-28.pdf                    
2011-11-28 16:10 geoffclare     Note Edited: 0001060                         
2011-11-28 16:38 dwheeler       Note Added: 0001061                          
2011-11-29 03:26 Roger Marquis  Note Added: 0001064                          
2011-11-29 03:27 Roger Marquis  Note Edited: 0001064                         
2011-11-29 04:51 dwheeler       Note Added: 0001065                          
2011-12-29 19:01 antoinel       Issue Monitored: antoinel                    
2013-10-10 01:15 dwheeler       Note Added: 0001869                          
2013-10-12 04:08 dwheeler       Note Added: 0001881                          
2013-10-24 15:15 geoffclare     File Added:
Extendingshellconditionals-2013-10-24.odt                    
2013-10-24 15:16 geoffclare     File Added:
Extendingshellconditionals-2013-10-24.pdf                    
2013-10-24 15:23 geoffclare     Note Added: 0001944                          
2013-10-25 10:26 geoffclare     Note Added: 0001945                          
2013-10-31 15:55 Don Cragun     Relationship added       has duplicate 0000762
2013-11-01 15:36 ranjit         Note Added: 0001950                          
2013-11-01 19:09 dwheeler       Note Added: 0001953                          
2013-11-01 19:43 shware_systems Note Added: 0001954                          
2013-11-10 14:46 dwheeler       Note Added: 0001979                          
2013-11-22 22:13 dwheeler       Note Added: 0002017                          
2013-11-29 18:56 dwheeler       File Added:
Extendingshellconditionals-2013-11-29.odt                    
2013-11-29 18:57 dwheeler       File Added:
Extendingshellconditionals-2013-11-29-track-changes.pdf                    
2013-11-29 18:58 dwheeler       File Added:
Extendingshellconditionals-2013-11-29.pdf                    
2013-11-29 19:11 dwheeler       Note Added: 0002031                          
2013-11-29 19:24 dwheeler       Note Added: 0002032                          
2013-12-01 22:52 jilles         Note Added: 0002033                          
2013-12-02 08:59 shware_systems Note Added: 0002034                          
2013-12-02 11:15 shware_systems Note Added: 0002035                          
2013-12-08 22:06 dwheeler       Note Added: 0002052                          
2013-12-08 22:48 dwheeler       Note Added: 0002053                          
2013-12-08 23:05 dwheeler       Note Added: 0002054                          
2013-12-09 01:32 dwheeler       File Added:
Extendingshellconditionals-2013-12-08.odt                    
2013-12-09 01:33 dwheeler       File Added:
Extendingshellconditionals-2013-12-08.pdf                    
2013-12-09 01:35 dwheeler       Note Added: 0002055                          
2013-12-09 06:55 shware_systems Note Added: 0002056                          
2013-12-10 04:46 dwheeler       Note Added: 0002059                          
2013-12-10 04:52 dwheeler       File Added:
Extendingshellconditionals-2013-12-09.odt                    
2013-12-10 04:53 dwheeler       File Added:
Extendingshellconditionals-2013-12-09.pdf                    
2013-12-10 09:41 shware_systems Note Added: 0002060                          
2013-12-10 16:08 dwheeler       Note Added: 0002061                          
2013-12-10 22:36 jilles         Note Added: 0002063                          
2013-12-11 00:46 dwheeler       Note Added: 0002064                          
2013-12-11 00:48 shware_systems Note Added: 0002065                          
2013-12-11 00:58 dwheeler       Note Added: 0002066                          
2013-12-12 01:38 shware_systems Note Added: 0002068                          
2013-12-12 06:04 shware_systems Note Edited: 0002068                         
2014-03-06 17:08 eblake         Relationship added       related to 0000813  
2014-03-06 17:15 geoffclare     Note Added: 0002176                          
2014-03-06 19:13 ranjit         Note Added: 0002177                          
2014-03-06 21:22 shware_systems Note Added: 0002178                          
2014-03-07 15:46 dwheeler       Note Added: 0002179                          
2014-03-07 15:52 dwheeler       Note Added: 0002180                          
2014-03-11 14:52 shware_systems Note Added: 0002181                          
2014-03-12 23:05 dwheeler       Note Added: 0002182                          
2014-03-14 13:25 ranjit         Note Added: 0002186                          
2014-10-13 16:44 rhansen        Note Added: 0002418                          
2014-10-13 16:52 geoffclare     Note Added: 0002419                          
2014-10-13 16:55 dwheeler       Note Added: 0002420                          
2014-10-13 17:54 rhansen        Note Added: 0002421                          
2016-09-19 21:46 stephane       Note Added: 0003382                          
2016-09-20 17:16 shware_systems Note Added: 0003383                          
2016-09-20 20:34 stephane       Note Added: 0003384                          
======================================================================


Reply via email to