Broken bash command substitution

L. A. Walsh cygwin@tlinx.org
Fri Nov 25 12:24:00 GMT 2016


Tydus wrote:
> 
> Dear list,
> 
> I use Cygwin64 for a long time and everything went well. However, after 
> one setup.exe update, the command substitution (`foo`) is broken on 
> bash.

----

You didn't specify what version of bash you are running.

Since here:

> $ ssh a-linux-server
> $ A=`echo 123 | cat`; echo "===$A===" #<-- Linux doesn't have problem 
> either
> ===123===
> $ exit
---
	You know that the main shell on linux is "bash".  
If it didn't happen on linux, that meant it didn't happen in
the bash on that linux.

	What version of bash was it running?

	Problems in bash are specific to specific versions
of bash -- so their version becomes important.  Using
"bash --version" should tell you.  If the versions are different
and the later version doesn't have your problem, something
may have changed to fix the problem.

	Also, FWIW, when I try your example on cygwin, I
got:
> unset A; A=`echo 123 | cat`; echo "===$A==="
===123===

	I.e - it seemed to work.

	Not that it makes a difference in
your test case, but I think use of backticks has been
replaced by a suggestion to use "$()", like:

> unset A; A=$(echo 123|cat); echo "===$A==="
===123===

	I think it was thought that "$()" hilighted
the subprocess more clearly as well as making it
more clear that the interior text is done in a 
sub process.

	FYI, my bash on cygwin is:

> bash --version
GNU bash, version 4.1.17(9)-release (x86_64-unknown-cygwin)



--
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



More information about the Cygwin mailing list