On 3/19/12 9:27 AM, Mark Edgar wrote:
> I've boiled the problem down to this:
>
> A=
> B=q
> echo "x${A+${B#q*}}x" | sed -nel
>
> Excluding the newline, the output I expect is "xx", but instead there
> is a delete character \177 between the two "x" characters.
Thanks for the wonderfully detailed bug report; that made the problem
easy to find and test. I've attached a patch which fixes the issue.
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-patched/subst.c 2012-03-11 17:35:13.000000000 -0400
--- subst.c 2012-03-20 19:30:13.000000000 -0400
***************
*** 5805,5808 ****
--- 5814,5827 ----
if (qdollaratp && ((hasdol && quoted) || l->next))
*qdollaratp = 1;
+ /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is
+ a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the
+ flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the
+ expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
+ (which is more paranoia than anything else), we need to return the
+ quoted null string and set the flags to indicate it. */
+ if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL(temp) && QUOTED_NULL(l->word->word) && (l->word->flags & W_HASQUOTEDNULL))
+ {
+ w->flags |= W_HASQUOTEDNULL;
+ }
dispose_words (l);
}