delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/02/13/11:55:30

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
From: Adam Dinwoodie <Adam DOT Dinwoodie AT metaswitch DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: RE: Is this a bug or a behavior?
Date: Wed, 13 Feb 2013 16:55:01 +0000
Deferred-Delivery: Wed, 13 Feb 2013 16:55:00 +0000
Message-ID: <CE9C056E12502146A72FD81290379E9A608E7C64@ENFIRHMBX1.datcon.co.uk>
References: <511BBBD4 DOT 8090902 AT fastmail DOT fm>
In-Reply-To: <511BBBD4.8090902@fastmail.fm>
MIME-Version: 1.0
X-IsSubscribed: yes
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id r1DGtQsX001874

Jack Radigan wrote:
> Using the following script:
> #!/bin/bash
> set -x
> cat << eof | `ls /bin | grep "^grep$"` alpha
> alpha
> omega
> eof

Easier repro showing this phenomena:

    ls /bin | grep '^grep$'

On Linux, you'll get "grep" as output.  Cygwin won't output anything.

> But, the command 'cp /bin/grep ~/.' will copy grep.exe to my home directory.

Yes.  If you ask for a file, the file doesn't exist, but the file with a .exe
extension exists, Cygwin will refer you to the .exe version of the file.  See
<http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-exe>.

> Shouldn't 'ls' be suppressing the '.exe' extension for cygwin binaries
> in the same way that 'cp' appends it?

No: ls tells you about what files actually exist.  "grep.exe" exists; "grep"
doesn't.

> Seems inconsistent not to.

From that point of view it is; Cygwin is self-consistent, but the very nature
of attempting to write a Linux-like interface on a fundamentally non-Linux like
OS means such issues can't be avoided.  Nobody has yet suggested a more
consistent alternative that still allows, for example, a Linux shell script
that calls unadorned "grep" to work on Cygwin.

If this is causing you a real problem that you can explain, the list may be
able to give you some assistance working around it.  For your (I really hope)
contrived example, replace the command substitution with "/bin/grep" for a
script that will work on both Linux and Cygwin.

-- 
Adam Dinwoodie

Messages posted to this list are made in a personal capacity.



--
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