[Top][All Lists]

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

Re: Bash-5.1-beta available

From: Oğuz
Subject: Re: Bash-5.1-beta available
Date: Fri, 11 Sep 2020 16:28:28 +0300

11 Eylül 2020 Cuma tarihinde Andreas Schwab <schwab@linux-m68k.org> yazdı:

> On Sep 10 2020, Chet Ramey wrote:
> > yy. Process substitution processes now get their input from /dev/null,
> since
> >     they are asynchronous, not interactive, and not jobs.
> That breaks scripts that want to filter stdin with a process
> substitution, eg:
> while read ...; do ...; done < <(filter)
> The reason for using a process substitution is so that the loop can set
> shell variables.

The loop can still set shell variables. Move the program that generates the
input for `filter' into the process substitution or if the script's stdin
is to be filtered just enable lastpipe.

    set -o lastpipe
    filter | while read ...; do ...; done

Allowing substituted processes to read from the shell's stdin doesn't make
any sense to me. The shell doesn't wait for those processes to complete
before reading the next command, so you can easily have two processes
racing to read from the same file handle if you allow substituted processes
to read from the shell's stdin. The command below for example, fills file1
and file2 with fragments of seq's output on bash 5.0.11.

    seq 1000000 | { : <(cat >file1); cat >file2; }

> Andreas.
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."


reply via email to

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