On 12/13/22 12:42 PM, Norbert Lange wrote:

Bash Version: 5.2
Patch Level: 2
Release Status: release

Description:
Parameter expansion within heredocs fails.

The code below works with other shells aswell as bash 5.1

Thanks for the report. It's an off-by-one error that is specific to command
substitution within parameter expansion in a here-document line. Here's a
patch.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/
*** ../bash-5.2-patched/subst.c 2022-12-13 12:08:58.000000000 -0500
--- subst.c     2022-12-14 09:09:53.000000000 -0500
***************
*** 1694,1698 ****
          CHECK_STRING_OVERRUN (i, si, slen, c);
  
!         tlen = si - i - 1;
          RESIZE_MALLOCED_BUFFER (result, result_index, tlen + 4, result_size, 
64);
          result[result_index++] = c;
--- 1699,1703 ----
          CHECK_STRING_OVERRUN (i, si, slen, c);
  
!         tlen = si - i - 2;
          RESIZE_MALLOCED_BUFFER (result, result_index, tlen + 4, result_size, 
64);
          result[result_index++] = c;
***************
*** 1714,1718 ****
          CHECK_STRING_OVERRUN (i, si, slen, c);
  
!         tlen = si - i - 1;
          RESIZE_MALLOCED_BUFFER (result, result_index, tlen + 4, result_size, 
64);
          result[result_index++] = c;
--- 1719,1723 ----
          CHECK_STRING_OVERRUN (i, si, slen, c);
  
!         tlen = si - i - 2;
          RESIZE_MALLOCED_BUFFER (result, result_index, tlen + 4, result_size, 
64);
          result[result_index++] = c;

Reply via email to