From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53696 invoked by alias); 3 Dec 2018 15:56:04 -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 53684 invoked by uid 89); 3 Dec 2018 15:56:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=BAYES_40,FREEMAIL_FROM,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=cyg, Bash, UD:hello.sh, BEGIN X-HELO: mail-it1-f173.google.com Received: from mail-it1-f173.google.com (HELO mail-it1-f173.google.com) (209.85.166.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Dec 2018 15:56:02 +0000 Received: by mail-it1-f173.google.com with SMTP id p197so9272209itp.0 for ; Mon, 03 Dec 2018 07:56:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=pzwAGbUmmMVaPwGIlu5k+Ei4sUMkmeXucHCyvbZ+JVg=; b=JaGwqHSsrWvOmDyhL8csYYeDKBV+IeIdb220I0xlr9AcLjZP4tleKWTwNLo1NAJO4P gX3n8cckOUfyrFoyov0dl1Sw02cKELsdxNB2lrp+aayrEtTxsqg+WVo7tWoeaXGpRKRh EeKwpBrNB0L+OLUXy+T2PUCe6/pxhp5507nZ1dNjBKXmTV36MW4dC1JrJ4LW92qfi7Bs h1J8y4q2+Y8haVpSsfstCvG0DcVqVZF9hNIRRZO0xcx+v0084nvWuVeW6Sz3CVj/uiwu hpXvKW57Cris6rsiPIz1mGR2PWvTXPkSpmEuF1N1xCpRqwQJwdutW/ChOT5rMA3pvtQf 8Jvw== Return-Path: Received: from [192.168.0.5] (d47-69-109-131.nap.wideopenwest.com. [69.47.131.109]) by smtp.gmail.com with ESMTPSA id 196sm897432itu.37.2018.12.03.07.55.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 07:55:59 -0800 (PST) Subject: Re: Bash heredoc on FD 3 To: cygwin@cygwin.com References: <5c0427c5.1c69fb81.d71e5.c8ec@mx.google.com> From: cyg Simple Message-ID: Date: Mon, 03 Dec 2018 15:56:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00035.txt.bz2 On 12/3/2018 10:43 AM, cyg Simple wrote: > > On 12/2/2018 1:43 PM, 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? > > Same for me and interestingly: > > $ ls -ld /dev/fd/* > ls: cannot access '/dev/fd/3': No such file or directory > ls: cannot access '/dev/fd/31': No such file or directory > lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec  3 10:39 /dev/fd/0 -> /dev/pty2 > lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec  3 10:39 /dev/fd/1 -> /dev/pty2 > lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec  3 10:39 /dev/fd/2 -> /dev/pty2 And: $ dash -c '/bin/ls -l /dev/fd/' total 0 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 0 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 1 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 2 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 3 -> /proc/27356/fd $ dash -c '/bin/ls -l /dev/fd/' total 0 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 0 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 1 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 2 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:51 3 -> /proc/18740/fd So in Bash the process is no longer available. Adding -d to the above: $ dash -c '/bin/ls -ld /dev/fd/*' /bin/ls: cannot access '/dev/fd/3': No such file or directory lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:50 /dev/fd/0 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:50 /dev/fd/1 -> /dev/pty2 lrwxrwxrwx 1 eboyd53 eboyd53 0 Dec 3 10:50 /dev/fd/2 -> /dev/pty2 -- cyg 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