Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread tetsujin
It's a fair point but I think there may be a reasonable middle-ground, in which common pitfalls are briefly addressed in TFM, but the manual doesn't become bogged down with exhaustive detail of every possible pitfall. After all, information overload would just become another thing preventing read

Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread Greg Wooledge
On Thu, Jun 29, 2017 at 03:22:24PM -0400, tetsu...@scope-eye.net wrote: > So I look at this not just as a RTFM issue, it's a pitfall built-in to > the design of the language, and programmers need to understand a bit > about the implementation of the language to understand what's going > on. As such

Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread tetsujin
I think that when programmers first learn shell programming, this is a hard piece of information to effectively convey. The Bash documentation provides the important facts: - Subshells are quietly and automatically constructed for a variety of shell programming constructs, including pipelines - C

Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread Chet Ramey
On 6/29/17 12:38 PM, Keith Thompson wrote: > I suggest that it would be worthwhile to mention this issue in the > documentation. "Each command in a pipeline is executed as a separate process (i.e., in a subshell). See COMMAND EXECUTION ENVIRONMENT for a description of a subshell environment.

Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread Keith Thompson
On Thu, Jun 29, 2017 at 6:56 AM, Eduardo A. Bustamante López wrote: > On Wed, Jun 28, 2017 at 07:08:27PM -0700, Keith Thompson wrote: > [...] >> mapfile REDIRECT < /tmp/input.txt >> cat /tmp/input.txt | mapfile PIPE > > The `mapfile PIPE' is a piece of a pipeline, and as such, it r

Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread Greg Wooledge
On Wed, Jun 28, 2017 at 07:08:27PM -0700, Keith Thompson wrote: > Description: > The "mapfile" command works correctly if stdin is redirected > from a file, but not if it's from a pipe. This is because each command in a pipeline is executed in its own subshell. Not a bug. If you need to r

Re: mapfile doesn't accept input from a pipe

2017-06-29 Thread Eduardo A . Bustamante López
On Wed, Jun 28, 2017 at 07:08:27PM -0700, Keith Thompson wrote: [...] > mapfile REDIRECT < /tmp/input.txt > cat /tmp/input.txt | mapfile PIPE The `mapfile PIPE' is a piece of a pipeline, and as such, it runs in a subshell (different process). See: http://mywiki.wooledge.org/BashFA