From: Houder <houder@xs4all.nl>
To: cygwin@cygwin.com
Subject: Re: Bash heredoc on FD 3
Date: Tue, 04 Dec 2018 12:13:00 -0000 [thread overview]
Message-ID: <c6d1ba2d6a7a0daa32aee92f806a30dd@smtp-cloud7.xs4all.net> (raw)
In-Reply-To: <5c0427c5.1c69fb81.d71e5.c8ec@mx.google.com>
On Sun, 02 Dec 2018 10:43:17, Steven Penny wrote:
> Using this file:
>
> $ cat hello.sh
> awk -f /dev/fd/3 3<<eof
> BEGIN {
> print "hello world"
> }
> eof
>
> it runs as expected with Dash:
>
> $ dash hello.sh
> hello world
>
> However it fails with Bash:
>
> $ bash hello.sh
> awk: fatal: can't open source file `/dev/fd/3' for reading (No such file or
> directory)
>
> I tried also with Debian and both Dash and Bash work as expected. What is
> causing Cygwin Bash to fail here?
File to which symlnk /dev/fd/3 refers has "gone"; different from Linux, where
the file is "deleted", but still "available".
(note: dash uses a different implementation)
I used fd 7 in testing. Below the output on Cygwin ... Observe the difference
when executed on Linux.
Henri
hello.sh:
#cat 7<<\EOF 0<&7 # works on both Linux and Cygwin
#cat 7<<\EOF 0<&7 /dev/fd/7 # fails on Cygwin
#ls 7<<\EOF 0<&7 -l /proc/self/fd /tmp /dev/fd/7
ls 7<<\EOF 0<&7 -lL /proc/self/fd /tmp /dev/fd/7
Hello world!
EOF
exit
# Using: ls 7<<\EOF 0<&7 -l /proc/self/fd /tmp /dev/fd/7
64-@@ bash hello.sh
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 /dev/fd/7 -> /tmp/sh-thd.3PSuc2
/proc/self/fd:
total 0
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 0 -> /tmp/sh-thd.3PSuc2
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 1 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 2 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 3 -> /proc/4972/fd
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 7 -> /tmp/sh-thd.3PSuc2
/tmp:
..
64-@@ dash hello.sh
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 /dev/fd/7 -> pipe:[4294969740]
/proc/self/fd:
total 0
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 0 -> pipe:[4294969740]
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 1 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 2 -> /dev/pty1
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 3 -> /proc/3740/fd
lrwxrwxrwx 1 Henri None 0 Dec 4 12:37 7 -> pipe:[4294969740]
/tmp:
..
# Using: ls 7<<\EOF 0<&7 -lL /proc/self/fd /tmp /dev/fd/7
64-@@ bash hello.sh
ls: cannot access '/dev/fd/7': No such file or directory
/proc/self/fd:
ls: cannot access '/proc/self/fd/0': No such file or directory
ls: cannot access '/proc/self/fd/7': No such file or directory
total 0
l????????? ? ? ? ? ? 0
crw--w---- 1 Henri None 136, 1 Dec 4 12:39 1
crw--w---- 1 Henri None 136, 1 Dec 4 12:39 2
dr-xr-xr-x 2 Henri None 0 Dec 4 12:39 3
l????????? ? ? ? ? ? 7
/tmp:
..
64-@@ dash hello.sh
prw------- 1 Henri None 0 Dec 4 12:40 /dev/fd/7
/proc/self/fd:
total 0
prw------- 1 Henri None 0 Dec 4 12:40 0
crw--w---- 1 Henri None 136, 1 Dec 4 12:40 1
crw--w---- 1 Henri None 136, 1 Dec 4 12:40 2
dr-xr-xr-x 2 Henri None 0 Dec 4 12:40 3
prw------- 1 Henri None 0 Dec 4 12:40 7
/tmp:
..
=====
--
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
next prev parent reply other threads:[~2018-12-04 12:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-02 18:43 Steven Penny
2018-12-03 15:43 ` cyg Simple
2018-12-03 15:56 ` cyg Simple
2018-12-03 17:28 ` Eliot Moss
2018-12-04 12:13 ` Houder [this message]
2018-12-04 14:22 ` cyg Simple
2018-12-05 6:55 ` Houder
2019-01-06 20:18 ` Corinna Vinschen
2019-01-07 18:28 ` Steven Penny
2019-01-07 19:03 ` Corinna Vinschen
2019-01-08 0:19 ` Steven Penny
2019-01-08 11:27 ` Corinna Vinschen
2019-01-08 21:05 ` Corinna Vinschen
2019-01-09 0:17 ` Steven Penny
2019-01-09 9:48 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6d1ba2d6a7a0daa32aee92f806a30dd@smtp-cloud7.xs4all.net \
--to=houder@xs4all.nl \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).