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

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

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 -

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

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

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:

Typo in bash manual: "QUANTUMP"

2017-06-29 Thread Keith Thompson
In the documentation for the "mapfile" builtin command: '-C' Evaluate CALLBACK each time QUANTUMP lines are read. The '-c' option specifies QUANTUM. "QUANTUMP" should be "QUANTUM". In the latest sources cloned from git://git.savannah.gnu.org/bash.git, this occurs in:

mapfile doesn't accept input from a pipe

2017-06-29 Thread Keith Thompson
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security uname output: Linux bomb20 4.8.0-46-generic #49-Ubuntu SMP Fri Mar 31 13:57:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux