A NOTE has been added to this issue. 
====================================================================== 
http://austingroupbugs.net/view.php?id=1234 
====================================================================== 
Reported By:                stephane
Assigned To:                
====================================================================== 
Project:                    1003.1(2016)/Issue7+TC2
Issue ID:                   1234
Category:                   Shell and Utilities
Type:                       Enhancement Request
Severity:                   Editorial
Priority:                   normal
Status:                     New
Name:                       Stephane Chazelas 
Organization:                
User Reference:              
Section:                    2.13.1 
Page Number:                2382 
Line Number:                76212-76215 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2019-03-08 23:58 UTC
Last Modified:              2019-03-12 15:11 UTC
====================================================================== 
Summary:                    in most shells, backslash doesn't have two meaning
wrt pattern matching
====================================================================== 

---------------------------------------------------------------------- 
 (0004318) kre (reporter) - 2019-03-12 15:11
 http://austingroupbugs.net/view.php?id=1234#c4318 
---------------------------------------------------------------------- 
Re http://austingroupbugs.net/view.php?id=1234#c4317

     "because when a backslash arrives at the shell globber, it is
literal,
      whereas it is an escape for find -name."

That's exactly what the issue is.   And what needs to change in order for
patterns in variables to work correctly.   And here, "change" means "be
interpreted in a reasonable way", all of that is actually correct as it
is.

Certainly a \ entered in a script (part of the shell input) is a quoting
character, and if it gets through to the pattern matching, it must have
been quoted (and as such be in a place where quote removal will be
performed, or at least would be, when used in a place where that happens).
That (quoted) \ which gets to the pattern matching code is certainly a
literal backslash, and simply matches itself.

But when we have
     var='\**.c'
(or similar) and then
     ls $var
(which becomes after parameter expansion)
     ls \**.c
that \**.c (as it is not the original text) is not subject to quote
removal
(only quoting characters that were in the original script get removed by
quote removal) and is "When pattern matching is used where shell quote
removal is not performed" and the "special characters can be escaped"
(as in the first '*') "by preceding them with a backslash character."
which is exactly what has been done here.

This is another case where the standard as written is correct, and doesn't
really need any changes - we just need to actually believe what it says,
and interpret it correctly. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2019-03-08 23:58 stephane       New Issue                                    
2019-03-08 23:58 stephane       Name                      => Stephane Chazelas
2019-03-08 23:58 stephane       Section                   => 2.13.1          
2019-03-08 23:58 stephane       Page Number               => 2382            
2019-03-08 23:58 stephane       Line Number               => 76212-76215     
2019-03-11 02:42 kre            Note Added: 0004296                          
2019-03-11 02:58 kre            Note Edited: 0004296                         
2019-03-11 03:07 kre            Note Edited: 0004296                         
2019-03-11 03:10 kre            Note Added: 0004297                          
2019-03-11 03:16 kre            Note Edited: 0004296                         
2019-03-11 03:23 kre            Note Added: 0004298                          
2019-03-11 07:24 stephane       Note Added: 0004300                          
2019-03-11 07:31 stephane       Note Added: 0004301                          
2019-03-11 09:41 geoffclare     Note Added: 0004303                          
2019-03-12 03:24 kre            Note Added: 0004306                          
2019-03-12 03:37 kre            Note Added: 0004307                          
2019-03-12 03:38 kre            Note Deleted: 0004297                        
2019-03-12 09:13 Konrad_Schwarz Note Added: 0004309                          
2019-03-12 09:58 geoffclare     Note Added: 0004310                          
2019-03-12 12:13 Don Cragun     Note Edited: 0004306                         
2019-03-12 12:14 Don Cragun     Note Edited: 0004306                         
2019-03-12 12:15 kre            Note Added: 0004313                          
2019-03-12 12:16 Don Cragun     Note Edited: 0004307                         
2019-03-12 12:23 kre            Note Added: 0004314                          
2019-03-12 12:24 kre            Note Edited: 0004314                         
2019-03-12 14:29 Konrad_Schwarz Note Added: 0004317                          
2019-03-12 14:56 kre            Note Edited: 0004313                         
2019-03-12 14:58 kre            Note Edited: 0004314                         
2019-03-12 15:11 kre            Note Added: 0004318                          
======================================================================


Reply via email to