This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bash pipe fails in script with subshell/loop cmbination

Hi all,

I've run into a problem regarding pipes in bash, in a command that
loops. I've reduced it to a very small one-liner that fails. The two
versions below should, I'm sure, give the same output - but they
don't. I know the command is silly and useless as it is shown here,
but it's what I'm left with from something more complex after removing
as much of the complexity as I could while retaining the actual
problem I'm fighting.

ONE - this works as expected
$ for j in 1 2;do echo $j $(echo hello);done
1 hello
2 hello

TWO - this fails, apparently (warning: my guess) at the pipe
$ for j in 1 2;do echo $j $(echo hello | cat);done

THREE - To make it that bit more obscure, the following command also
works as it should, which by now I did not expect:
$ echo hello $(echo world | cat)
hello world

If 'cat' (in TWO) is replaced by 'od -a', then od does not generate
any output (at all) either. Can someone tell me what's wrong either in
what happens or in my expectation?

I have found someone on stackexchange who may, I think, be related
but unfortunately that was not resolved. I tried it with virusscanning
switched off - no difference.

Thanks for looking!

Wouter van Doorn

Attachment: cygcheck.txt
Description: Text document

Attachment: installed.db
Description: Binary data

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]