mainThe GNU Bourne-Again SHell - Support: sr #108110, [bug] righthand of = or == in [[...

 
 

sr #108110: [bug] righthand of = or == in [[ ]] seems to do quote removal on expanded variables

Submitter:  Michal Soltys <msoltyspl>
Submitted:  Fri 17 Aug 2012 11:40:52 PM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 13 Nov 2015 02:35:45 PM UTC, comment #2: 

Not a bug.  When == or = is used with the [[ compound command, it performs pattern matching.  There is no quote removal performed, so the backslash is preserved, but the backslash has special meaning to the pattern matcher.  There is no difference between == and =, both perform pattern matching.

That's why you can quote the rhs to get string matching.

Chet Ramey <chet>
Group administrator
Fri 24 Aug 2012 10:26:33 AM UTC, comment #1: 

One correction: for == operator the behavior is fine (righthand is treated as a pattern and in such case backslash is removed), but for = it's still invalid.

Michal Soltys <msoltyspl>
Fri 17 Aug 2012 11:40:52 PM UTC, original submission:  

Essentially, if someone does:

set -x
a='test\test'
[[ $a = $a ]]

Then the result (as of 4.2.37) will be false (even though debug output shows expected evaluation). The only way to get true is to quote righthand $a (or both). If I'm not missing any subtlety - I think it's not how it should be - as it looks like quote removal is sneaking in at some point modifying effects of earlier expansions.


Michal Soltys <msoltyspl>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by msoltyspl (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-13 chet StatusNone Invalid

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code