On Thu, Mar 15, 2007 at 01:11:31PM +0100, Jens Stroebel wrote:
> Reading your posts, I got and applied the above-mentioned patch;
> contrary to what I expected, [[ $test =~ $regexpr ]] worked, whereas
> [[ "$test" =~ "$regexpr" ]] did not. See below:
>
> =============================================================================
> [EMAIL PROTECTED]:/usr/src/rpm> if [[ "sploerp" =~ "s.*rp" ]] ; then echo yes
> ; fi
> [EMAIL PROTECTED]:/usr/src/rpm> if [[ sploerp =~ s.*rp ]] ; then echo yes ; fi
> yes
> =============================================================================
Following up my own post, sorry, but I thought the above incomplete after
a bit more testing:
It seems like it's OK to "" the left side of the comparison,
but not the regex which should be matched:
=============================================================================
[EMAIL PROTECTED]:~/make> if [[ "sploerp" =~ s.*rp ]] ; then echo yes ; fi
yes
=============================================================================
If the regex-pattern is ill-suited to be matched without somehow "enclosing" it,
round brackets seem to work fine (which is to be expected, but I thought
I'd mention it anyway...)
=============================================================================
[EMAIL PROTECTED]:~/make> if [[ "sploerp" =~ s[ ]*.*rp ]] ; then echo yes ; fi
bash: syntax error in conditional expression
bash: syntax error near `]*.*rp'
[EMAIL PROTECTED]:~/make> if [[ "sploerp" =~ (s[ ]*.*rp) ]] ; then echo yes ; fi
yes
=============================================================================
greets,
Jens
--
[EMAIL PROTECTED]
23.....56.......drifting
By caffeine alone I set my mind in motion, By the beans of Java
do thoughts acquire speed, hands acquire shaking, the shaking
becomes a warning, By caffeine alone do I set my mind in motion
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page