X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:to:subject:references :content-type; q=dns; s=default; b=UAdpBNkCWRcverYRSlazTUFnk5ryW RxqVSWLQpkHkfZw2P5czHlxJKzMkAPrJqaz2g8CcFiHXDgUFznu1aWoBF36B8QdE O7jzElD5Gp0lxu72lfABUU+qq54SsKFUx+rCzwhA3FRm4WZvYTWBAb8vT3doVWLk vE+UgyGpuaGukQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:to:subject:references :content-type; s=default; bh=K2ZP45Btt/xiOwY9mvNyRkURGI4=; b=UkF +RU4bEjGlDTUBJeok8rTNTFeOzreFK8+r5V45kTpgzXBf+spD6YbPNh1NLl0mc04 EMCXKviXYygzMLNP0wjZfq73oyzk0sROzPH8AvXAM4Mien0KIVQUUnKeKvZhEaZE 9mezDB/jvjn/8PJA3hFX3KxwzokFayoGJh0NCbys= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=redirect, H*M:1c69fb81, H*M:google X-HELO: mail-oi0-f51.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:to:subject:references:user-agent; bh=PChy9o7WAG6iXJXV2PdpfqNbnYm62kdYVna0fqoK9Yg=; b=ASxHiXeMZ2gZvoo2Yzi117Extct2MQ9qdiLivSF2LCcwbvoJDfJU18DqkwNP9MPPwF 4c2Kjxpf15ywxWg8Vmi9MBH2FIMAVJqphb4uK+vm6Lk0dYx01Es+5RnQmecc3eKY/Npg uzAgcGafbepot5Meb/CY4crh8VA7fxRT5JTdo5sGOEyJZmcQttNL9nX5PouXoKGmJRUp xeTsP0q6/A5B3OIITx/SSI5FpAiH+2W5q3/35O3r9gbv6og76FYZexfbbOPJdXcKMl8I Vk/c1cRb6UuC2FwIAA3eLfPqxEQ7PKhciDdN+A4DM0wdfHFeU/zd2Qfj6cNVPSA37aMB sosA== Message-ID: <5b4bef8a.1c69fb81.33aa5.63f9@mx.google.com> Date: Sun, 15 Jul 2018 18:06:18 -0700 (PDT) From: Steven Penny To: cygwin AT cygwin DOT com Subject: Re: BASH 4.4 mapfile/readarray/read builtins mis-behaving with pipe References: <69b0bc3c-7ead-920e-f04b-ec631c3453b7 AT verizon DOT net> Content-Type: text/plain; charset=utf8; format=flowed User-Agent: Tryst/2.7.0 (github.com/svnpenn/tryst) 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 < read < some_unix_fmt_file > read < 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