On 2/18/11 9:06 PM, Mike Frysinger wrote:
> this simple code no longer works in bash-4.2:
> $ f=abc; echo ${f##""a}
> abc
> same goes for ${f//""a} and ${f%%""c}, and perhaps more operations
One more: everything that calls getpattern().
> removing the quotes, or quoting the single char in question, makes it work:
> $ f=abc; echo ${f##a} ${f##"a"}
> bc bc
>
> the original bug report uses variables in the pattern and quotes them to
> avoid
> expansion of globs and such. but if the variable happened to be empty,
> things
> no longer worked correctly.
Try this patch.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2/subst.c 2011-01-02 16:12:51.000000000 -0500
--- subst.c 2011-02-18 22:30:13.000000000 -0500
***************
*** 3371,3377 ****
if (string == 0 || *string == '\0')
return (WORD_LIST *)NULL;
! td.flags = 0;
td.word = string;
tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
return (tresult);
--- 3375,3381 ----
if (string == 0 || *string == '\0')
return (WORD_LIST *)NULL;
! td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */
td.word = string;
tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at);
return (tresult);