Bug 672714 - ambiguous meaning of $ after =~
Summary: ambiguous meaning of $ after =~
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 14
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Roman Rakus
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-25 23:53 UTC by Curtis Doty
Modified: 2014-01-13 00:13 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-01-26 14:21:05 UTC
Type: ---


Attachments (Terms of Use)

Description Curtis Doty 2011-01-25 23:53:29 UTC
Related to bug 652211...

This expression worked on f<13, but was b0rk by removal of the cond-rmatch patch:

( echo $BASH_VERSION ; b=foo ; [[ $b-42 =~ "^$b-[0-9][0-9]\$" ]] && echo right || echo wrong )
4.0.38(1)-release
right

( echo $BASH_VERSION ; b=foo ; [[ $b-42 =~ "^$b-[0-9][0-9]\$" ]] && echo right || echo wrong )
4.1.7(1)-release
wrong

So, apparently the fix is to remove the quotes. But the only way to get the trailing $ to properly match EOL is to also not escape it.

( b=foo ; [[ $b-42 =~ ^$b-[0-9][0-9]\$ ]] && echo right || echo wrong )
wrong

Which still leaves some ambiguity over what purpose the $ symbol has in that context.

( b=foo ; [[ $b-42 =~ ^$b-[0-9][0-9]$ ]] && echo right || echo wrong )
right

Comment 1 Roman Rakus 2011-01-26 14:21:05 UTC
It's not. It is parsed as expected. `$' is followed by `b' so it's variable expansion. The last `$' is followed by space ` ' so it's processed as single `$' and in Pattern Matching means match the EOL. So, no ambiguity.


Note You need to log in before you can comment on or make changes to this bug.