This is the mail archive of the
cygwin
mailing list for the Cygwin project.
/dev/stderr invalid with nested and chained redirections
- From: "cygwin-mailinglist" <cygwin-mailinglist at schneiderp dot de>
- To: cygwin at cygwin dot com
- Date: Mon, 10 Jul 2017 09:18:03 +0200
- Subject: /dev/stderr invalid with nested and chained redirections
- Authentication-results: sourceware.org; auth=none
- Reply-to: cygwin-mailinglist at schneiderp dot de
I have a script which does not find /dev/stderr when its stderr is
redirected and piped. The minimal reproduction follows below. This is a
verbatim copy from the terminal with edited-in comments prefixed with
hashes.
$ uname -a
CYGWIN_NT-6.1-WOW xxxxxxxx 2.8.1(0.312/5/3) 2017-07-03 14:06 i686 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (i686-pc-cygwin)
[...]
########################################################
$ cat say-something.sh
#!/bin/sh
echo something > /dev/stderr
########################################################
############### This is the error:
$ (x=$(./say-something.sh 2> /dev/stderr)) |& cat
./say-something.sh: line 2: /dev/stderr: No such file or directory
############### Variants without sub-shell, piping or redirection work:
$ (x=$(./say-something.sh 2> /dev/stderr)) | cat
something
$ (x=$(./say-something.sh 2> /dev/stderr))
something
$ x=$(./say-something.sh 2> /dev/stderr) |& cat
something
$ (x=$(./say-something.sh > /dev/stderr)) |& cat
something
$ (x=$(./say-something.sh 2> /dev/stdout)) |& cat
$
--
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