You are right, thank you for the explanation.

Alex.

-----Original Message-----
From: cygwin-ow...@cygwin.com [mailto:cygwin-ow...@cygwin.com] On Behalf Of
Michel LaBarre
Sent: Wednesday, February 28, 2018 7:02 PM
To: 'Alexander Pelevin'; cygwin@cygwin.com
Subject: RE: Possible output redirect bug

> Subject: Possible output redirect bug
> 
> Error output is not suppressed:
> 
> 
> $ cygstart cmd /c "(  >&2 pause ) >> test.txt"
> 
> $ cat /dev/null >> test.txt >/dev/null 2>&1
> bash: test.txt: Device or resource busy

The error message is not from the process running "cat" which is to what the
redirections apply.
The message is coming from the shell trying to setup file descriptors to
pass to the process running "cat" - you can see "bash:"
The shell cannot open the file for appending.

A simpler demonstration is:
$ cat < zorch > /dev/null 2>&1
bash: zorch: No such file or directory

Alternately:
$ ls zorch
ls: cannot access 'zorch': No such file or directory

shows std err is from "ls" and:
$ ls zorch 2> /dev/null
$
demonstrates redirection working.

Try instead:
( cat /dev/null >> test.txt ) >/dev/null 2>&1

Cheers,
Michel



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



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

Reply via email to