[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read doesn't work with piped stdin
From: |
Pierre Gaston |
Subject: |
Re: read doesn't work with piped stdin |
Date: |
Mon, 19 Nov 2007 10:10:03 +0200 |
> Description:
> read silently fails when stdin is piped to it. -u switch does not
> help.
> Redirection works fine.
>
This and your other bug result from the fact that the commands in the
pipe run in subshells.
echo foo | read # doesn't work because a subshell cannot modify the
parent process
echo foo | exit # only exits the subshell
exit < file # works because the redirection doesn't create a subshell
read var <<< foo # again no subshell here
It's the same thing as if you try: (read foo) or (exit foo)
see also:
http://wooledge.org:8000/BashFAQ#24