Web lists-archives.com

Re: Pipe after Command Substitution does not resolve the substitution:




On 14/06/2017 09:41, Jon Bord wrote:
Hi,

This is the first time i've ever submitted a bug report so i hope the
below is ok. I am not a programmer although i do do some scripting.

The below is the kind of 'command substitution then pipe' that i often
used in Cygwin on Windows 7.  Now that i've been forced to move to
Windows 10 it no longer seems to work. I'm assuming that this is not a
feature of an upgraded Bash but maybe i'm wrong, eg maybe we are now
supposed to put everything in variables rather than use command
substitution.

Windows 10
bash 4.4.11(2) and 4.4.12(3)

$ set -xv

(EXAMPLE 1: COMMAND SUBSTITUTION WORKS AS EXPECTED)
$ grep 2 $(ls | tail -1)
grep 2 $(ls | tail -1)
++ ls
++ tail -1
+ grep 2 test.txt
2
23

(EXAMPLE 2: HANGS)
$ grep 2 $(ls | tail -1)  | grep 3
grep 2 $(ls | tail -1)  | grep 3
+ grep 3
+ grep 2

(EXAMPLE 3: HANGS)
$ grep 2 `ls | tail -1` | grep 3
grep 2 `ls | tail -1` | grep 3
+ grep 3
+ grep 2

Would it be correct to conclude from the above output that once the
pipe is added then it is ignoring the substitution?


Hi Jon,
all the examples work for me on W7 64 with cygwin 64bit.

 $ ls
prova.txt

$ cat prova.txt
1
2
3
23

$ grep 2 $(ls | tail -1)
2
23

$ grep 2 $(ls | tail -1)  | grep 3
23

$ grep 2 `ls | tail -1` | grep 3
23

can you provide your cygcheck.out  ?
Problem reports:       http://cygwin.com/problems.html



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