Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: felix Newsgroups: gnu.bash.bug Subject: Re: Command substitution Date: Wed, 3 Jun 2020 08:38:50 +0200 Lines: 88 Approved: bug-bash@gnu.org Message-ID: References: <87mu5kgbxu.fsf@hobgoblin.ariadne.com> <20200603063850.GH8205@medium.hauri> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1591166340 13899 209.51.188.17 (3 Jun 2020 06:39:00 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: <87mu5kgbxu.fsf@hobgoblin.ariadne.com> User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: none client-ip=212.74.161.16; envelope-from=felix@f-hauri.ch; helo=smtp.f-hauri.ch X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 02:38:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: <20200603063850.GH8205@medium.hauri> X-Mailman-Original-References: <87mu5kgbxu.fsf@hobgoblin.ariadne.com> Xref: csiph.com gnu.bash.bug:16357 Quoting is useless when assigning variable from ouptut of command or another variable: $ foo=1 2 3 4 bash: 2: command not found Ok. But $ foo=$(seq 1 3) $ declare -p foo declare -- foo="1 2 3" $ foo="$(seq 1 3)" $ declare -p foo declare -- foo="1 2 3" No difference with or without double-quote. $ bar=$foo $ declare -p bar declare -- bar="1 2 3" $ bar="$foo" $ declare -p bar declare -- bar="1 2 3" Again, double-quoting is useless. But for commands: $ printf "<%s>\n" $foo <1> <2> <3> $ printf "<%s>\n" "$foo" <1 2 3> Same than $ printf "<%s>\n" $(seq 1 3) <1> <2> <3> $ printf "<%s>\n" "$(seq 1 3)" <1 2 3> Unfortunely, I don't retrieve this behaviour in man page. On Tue, Jun 02, 2020 at 09:44:45PM -0400, Dale R. Worley wrote: > Naively, I expect that > > FOO="$( command2 )" > command1 $FOO > > has the same effect as > > command1 $( command2 ) > > and > > FOO="$( command2 )" > command1 "$FOO" > > has the same effect as > > command1 "$( command2 )" > > Has anyone pushed the boundaries of this and can tell me whether there > are gotchas? > > Dale > -- Félix Hauri - - http://www.f-hauri.ch