On Mon, Aug 01, 2022 at 04:37:18PM +0900, Dominique Martinet wrote: > Harald Dunkel wrote on Mon, Aug 01, 2022 at 09:08:40AM +0200: > > a colleague pointed me to a changed behavior of bash 5.1.4 in Debian 11. > > ---- > > #! /bin/bash > > # set -x > > > > insert() > > { > > local data="$1" > > local lineNumber="$2" > > > > head -n "$lineNumber" > > The problem is that stdin is eaten up by this head command. > > What changed is that bash used to store stdin input in a temporary file, > so head could seek back to the actual position in the stream after the > first three lines but that no longer works:
Specifically, this part of the bash 5.1 changelog: c. Here documents and here strings now use pipes for the expanded document if it's smaller than the pipe buffer size, reverting to temporary files if it's larger.