Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Martijn Dekker Newsgroups: gnu.bash.bug Subject: Re: x[ Date: Tue, 30 Jul 2019 00:01:17 +0200 Lines: 86 Approved: bug-bash@gnu.org Message-ID: References: <9EA25AF1-6D80-456A-81FA-6D908072E624@gmail.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1564437695 31901 209.51.188.17 (29 Jul 2019 22:01:35 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 In-Reply-To: Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 37.59.109.123 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <9EA25AF1-6D80-456A-81FA-6D908072E624@gmail.com> Xref: csiph.com gnu.bash.bug:15270 Op 29-07-19 om 19:09 schreef Eli Schwartz: > The initial workaround discovered, was to use > > $ function _[ () { echo hello; }; <() _[ > hello > > The use of <() somehow suppresses the glitch in the same way that > quoting it does. If it were just glob expansion, then why should that be so? As others pointed out, it's the start of an array assignment, and associative array indexes can contain newlines. So we can de-obfuscate the issue by looking at a simple variable assignment 'x=foo' instead. Consider: $ function x=foo { echo hello; }; <() x=foo hello However: $ function x=foo { echo hello; }; (process substitution), a file name to which to write that command's input). Because that command is empty in this instance, bash does not bother to substitute a file name, and the <() is substituted by nothing. So, let's get rid of the function (because it is a distraction) and just see how 'x=foo' is parsed in substitutions and redirections: $ <() x=foo bash: x=foo: command not found $ $() x=foo bash: x=foo: command not found $ `` x=foo bash: x=foo: command not found $ ' and not with $ like every other kind of substitution and expansion (except obsolete `command substitutions`). It confuses people into thinking of it in terms of redirection, which is very misleading. By the way, in modernish, I've re-implemented process substitution in a form usable by all POSIX shells (including simple ones like dash), as a form of command substitution: $( % your command here ) # like <(your command here) $( % -o your command here ) # like >(your command here) -- modernish -- harness the shell https://github.com/modernish/modernish