chip@UUNET.UU.NET (Chip Salzenberg) (02/06/90)
As distributed, Bash 1.04 fails to distinguish between "`cmd`" and
`cmd`. In particular, the quoted form is supposed to preserve all
whitespace output by the command, except for a final newline, which
should be stripped. The below patch fixes this bug.
Index: subst.c
***************
*** 1053,1058 ****
istring_size += DEFAULT_ARRAY_SIZE);
! if (whitespace (c) || c == '\n')
{
if (!whitespace (lastc) && lastc != '\n')
istring[istring_index++] = ' ';
--- 1053,1062 ----
istring_size += DEFAULT_ARRAY_SIZE);
! if (quoted)
{
+ istring[istring_index++] = c | 0x80;
+ }
+ else if (whitespace (c) || c == '\n')
+ {
if (!whitespace (lastc) && lastc != '\n')
istring[istring_index++] = ' ';
***************
*** 1073,1079 ****
free (temp);
! strip_leading (istring + start_index);
! strip_trailing (istring + start_index);
! istring_index = strlen (istring);
goto next_character;
}
--- 1077,1092 ----
free (temp);
! if (quoted)
! {
! if (istring_index > 0 &&
! (istring[istring_index - 1] & 0x7F) == '\n')
! istring[--istring_index] = '\0';
! }
! else
! {
! strip_leading (istring + start_index);
! strip_trailing (istring + start_index);
! istring_index = strlen (istring);
! }
goto next_character;
}
--
Chip Salzenberg at ComDev/TCT <chip%tct@ateng.com>, <uunet!ateng!tct!chip>