delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/12/04/07:13:48

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:message-id:from:reply-to:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=uOMb2p
4tLU19o4iyP+3RmMcZgVf+foAFStPwoGMNvLyS12MfdiwG/steqfxR2kOKp2Wf8f
MZG1VnF9h2mANWFcxUCNWWs4HszOqcIj3XfLhsmmVUfLHx6Z6CAny6TbFs8xlvAU
uFj+zcyu7fOb9mS6zB+xAhrCClTCTXlUKT66E=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:message-id:from:reply-to:to:subject
:references:in-reply-to:content-type; s=default; bh=fBO1er9+82gV
EoHVbF7BDAmDODg=; b=ZDaXAYar+JIX9tDCSqUkNyUlzNlqefqZFiGFEUVdWilm
E690pffxrFDAduRVmpJZJ3bA2hFSAceDu1B3e0XgxyF9vNQL6mx1fUkDmlFc1+4p
2Li2Jgu2XmwSXQJ7zwASrqnQ1YdlKZ7t32CPeR9IiqzImWXqx6MImNBM4NOihiE=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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
Date: Tue, 04 Dec 2018 13:13:31 +0100
Message-ID: <c6d1ba2d6a7a0daa32aee92f806a30dd@smtp-cloud7.xs4all.net>
From: Houder <houder AT xs4all DOT nl>
Reply-To: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: Bash heredoc on FD 3
References: <5c0427c5 DOT 1c69fb81 DOT d71e5 DOT c8ec AT mx DOT google DOT com>
In-Reply-to: <5c0427c5.1c69fb81.d71e5.c8ec@mx.google.com>
User-Agent: mua.awk 0.99

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019