...
Using backquotes instead of the command
substitution with $(...) does not change the
results. I could swear this did work in an
earlier version of Cygwin on my Windows 7 machine.
I tried this to see if the code in the parentheses is executed at all:
$ value="$( date 2> foo | cat )"; echo "$? <$value>"
The file "foo" was not created, i.e., it seems
the commands don't really get executed.
$ value="$( date && pwd )"; echo "$? <$value>"
0 <Tue Jul 11 20:49:09 CEST 2017
/home/juergen>
$ value="$( date || pwd )"; echo "$? <$value>"
0 <Tue Jul 11 20:32:27 CEST 2017>
both work, so some control structures seem to be
permissible... just not a pipe.
What is going on? Some misconfiguration? A
Cygwin bug? Some interaction with something
weird in Windows 10? I am at loss to understand
what could be wrong... and am now most curious
whether anybody has an idea what is causing
this. Does it work/not work in the same way in your Cygwin installation?
I came across this effect because
ssh-host-config did not recognize me as
administrator anymore. It's due to a check for a
certain user group that uses a command
substitution with a pipe. Replacing this with an
equivalent command works. The original line used
"id -G" and then a "grep -Eq" to check whether a certain group is on that list.
I am VERY curious now! I've rarely been puzzled
that much by such a very elementary shell
expression (looking back at 34 years of Unix experience).