delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/12/19/10:23:04

X-Spam-Check-By: sourceware.org
Message-ID: <43A6D04E.6020306@hones.org.uk>
Date: Mon, 19 Dec 2005 15:22:54 +0000
From: Cliff Hones <cliff AT hones DOT org DOT uk>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: Volker Quetschke <quetschke AT scytek DOT de>
CC: cygwin AT cygwin DOT com
Subject: Re: test -e cannot distinguish between foo and foo.exe
References: <43A6CDA0 DOT 8060508 AT scytek DOT de>
In-Reply-To: <43A6CDA0.8060508@scytek.de>
X-Spam-Score: -2.3 (--)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

Volker Quetschke wrote:
> I noticed the following behaviour: (found by my favorite testcase ;) )
> 
> $ rm -rf foo* ; touch foo.exe
> 
> $ test -e foo && echo found foo
> found foo
> 
> $ test -e foo.exe && echo found foo.exe
> found foo.exe
> 
> Hmm, how can I test if foo exists without also looking at foo.exe?
> Does this count as a bug in test?
> 
> My current workaround is
> 
> $ find . -maxdepth 1 -name foo -exec echo _XfoundX_ \; | grep _XfoundX_ >
> /dev/null && echo found foo
> 
> but that is a bit ugly.

Much simpler than that:

  test -e foo. && echo found foo.

The trailing dot excludes the .exe magic and is ignored on translation to windows filename.

-- Cliff



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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