From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113911 invoked by alias); 4 Dec 2018 12:13:38 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 113896 invoked by uid 89); 4 Dec 2018 12:13:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=BAYES_50,GIT_PATCH_2,KAM_NUMSUBJECT,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Below, dash, Bash, hellosh X-HELO: lb1-smtp-cloud7.xs4all.net Received: from lb1-smtp-cloud7.xs4all.net (HELO lb1-smtp-cloud7.xs4all.net) (194.109.24.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Dec 2018 12:13:34 +0000 Received: from tmp.7EiazPWaFr ([83.162.234.136]) by smtp-cloud7.xs4all.net with ESMTPSA id U9ZxgsXsnaOW5U9ZygFP9O; Tue, 04 Dec 2018 13:13:31 +0100 Date: Tue, 04 Dec 2018 12:13:00 -0000 Message-ID: From: Houder Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com Subject: Re: Bash heredoc on FD 3 References: <5c0427c5.1c69fb81.d71e5.c8ec@mx.google.com> In-Reply-to: <5c0427c5.1c69fb81.d71e5.c8ec@mx.google.com> Content-Type: text/plain; charset=UTF-8; format=fixed User-Agent: mua.awk 0.99 X-SW-Source: 2018-12/txt/msg00040.txt.bz2 On Sun, 02 Dec 2018 10:43:17, Steven Penny wrote: > Using this file: > > $ cat hello.sh > awk -f /dev/fd/3 3< 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