bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

5.1 regression?


From: Harald Dunkel
Subject: 5.1 regression?
Date: Mon, 1 Aug 2022 09:08:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0

Hi folks,

a colleague pointed me to a changed behavior of bash 5.1.4 in Debian 11.
Would you mind to take a look at this code?

----
#! /bin/bash
# set -x

insert()
{
   local data="$1"
   local lineNumber="$2"

   head -n "$lineNumber"

   echo '   <!-- BEGIN inserted by '"$( basename "$0" )"' -->'
   cat <<< "$data"
   echo '   <!-- END inserted by '"$( basename "$0" )"' -->'

   cat
}

text="this is line one
this is line two
this is line three
this is line four
this is line five
this is line six
this is line seven"

output="$( insert "Hello" 3 <<< "${text}" )"
echo "$output"
----


On bash 5.0.3 (Debian 10) it shows

----
this is line one
this is line two
this is line three
   <!-- BEGIN inserted by works_on_deb10_but_not_deb11 -->
Hello
   <!-- END inserted by works_on_deb10_but_not_deb11 -->
this is line four
this is line five
this is line six
this is line seven
----


On bash 5.1.4 (Debian 11) and 5.1.6 (openBSD 7.1) I get
----
this is line one
this is line two
this is line three
   <!-- BEGIN inserted by works_on_deb10_but_not_deb11 -->
Hello
   <!-- END inserted by works_on_deb10_but_not_deb11 -->
----


Lines 4 to 7 are lost. How comes? Is this a problem of
bash at all?


Every insightful comment is highly appreciated

Harri



reply via email to

[Prev in Thread] Current Thread [Next in Thread]