public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Steven Penny <svnpenn@gmail.com>
To: cygwin@cygwin.com
Subject: Re: BASH 4.4 mapfile/readarray/read builtins mis-behaving with pipe
Date: Tue, 17 Jul 2018 12:57:00 -0000	[thread overview]
Message-ID: <5b4bef8a.1c69fb81.33aa5.63f9@mx.google.com> (raw)
In-Reply-To: <69b0bc3c-7ead-920e-f04b-ec631c3453b7@verizon.net>

On Sun, 15 Jul 2018 19:01:21, BloomingAzaleas wrote:
> CASE:
> echo multi-line_arg | read foo
> cat multi-line_unix_fmt_file | read foo
>  =C2=A0RESULT:
> Fail with variable foo null or unset
>
> CASES: left chev re-directions
> mapfile < some_unix_fmt_file
> mapfile <<END multi-line_here_doc
> read < some_unix_fmt_file
> read <<END multi-line_here_doc
> RESULT:
> Work as expected
>
> CASES: mapfile or read in a sub-shell
> echo multi-line_arg | ( mapfile ; stuff )
> echo multi-line_arg | ( read foo; stuff )
> RESULT:
> Work as expected.=C2=A0 However, since mapfile/read result vars are=20
> not accessible in parent shell context, can force a notable=20
> re-structuring of a script to use sub-shells.

no mis-behaving: this is intended behavior - you yourself have given
workarounds: either redirect output to a file that can be later read, or pipe to
command grouping ala {} or () and read stdin from inside the subshell

im not sure what you are asking here - it seems you have a grasp already of the
"problem" and "solution" - so nothing more needs to be said really, as nothing
needs to be fixed - another option is "lastpipe"

http://mywiki.wooledge.org/BashFAQ/024


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2018-07-16  1:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 12:57 BloomingAzaleas
2018-07-17 12:57 ` Steven Penny [this message]
2018-07-18 11:17 ` BASH 4.4 mapfile/readarray/read builtins mis-behaving with pipe [edit] documentation bug BloomingAzaleas
2018-07-21  1:19   ` Eric Blake
2018-07-22  5:42     ` BloomingAzaleas
2018-07-23  2:15       ` Steven Penny
2018-07-23  6:32         ` Brian Inglis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b4bef8a.1c69fb81.33aa5.63f9@mx.google.com \
    --to=svnpenn@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).