Path: csiph.com!aioe.org!news.glorb.com!usenet.stanford.edu!not-for-mail From: Stephane Chazelas Newsgroups: gnu.bash.bug Subject: Re: substitution "read all from fd" silently fails: $(<&0) Date: Thu, 2 Jul 2015 09:49:13 +0100 Lines: 42 Approved: bug-bash@gnu.org Message-ID: References: <1994266822.20150701221910@gmail.com> <20150701214802.GC6739@chaz.gmail.com> <5594AFA7.9020904@draigBrady.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1435843642 31879 208.118.235.17 (2 Jul 2015 13:27:22 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 2.217.126.102 Content-Disposition: inline In-Reply-To: <5594AFA7.9020904@draigBrady.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-Mailman-Approved-At: Thu, 02 Jul 2015 09:27:20 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: aioe.org gnu.bash.bug:11150 2015-07-02 04:27:35 +0100, Pádraig Brady: [...] > > $( > execute /bin/cat in that process, it does the reading (from > > file) and writing (to the pipe) by itself (and the parent reads > > from the other end of the pipe to make-up the substitution). > > > > ksh (ksh93 and mksh) and zsh do not spawn a process in the > > $( > For completeness dash ignores this format so it's quite non portable [...] Yes, the behaviour is allowed but unspecified by POSIX so one shouldn't use $( With the $(command) form, all characters following the SUS4> open parenthesis to the matching closing parenthesis SUS4> constitute the command. Any valid shell script can be used SUS4> for command, except a script consisting solely of SUS4> redirections which produces unspecified results. yash doesn't support it either. For bash and ksh, that only works properly if there's one "<" redirection on fd 0 ($(file)). For ksh, $( foo < other-redirection < $(even-that)), all the other redirections past the first one are ignored. For bash, if there's more than one redirection, that reverts to the normal null command behaviour like not in command substitution. zsh behaves like bash except that when not in sh emulation, the normal null command behaviour involves running cat. -- Stephane