I'm trying to capture the output of a command substitution. This works until a pipe is added to the command. Am I doing something wrong or is this a quirk of mingw?

$ bash --version
GNU bash, version 4.3.46(2)-release (x86_64-pc-msys)
$ echo $(ls | wc -l)
$ test=$(ls | wc -l); echo test="$test"

1 Answer 1


This looks like a quirk of mingw:

$ test=$(ls | wc -l); echo test="$test"
$ bash --version
GNU bash, version 4.3.43(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
  • Yeah... just noticed it is creating a stackdump. :/ Commented Jun 19, 2017 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .