This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: test -e cannot distinguish between foo and foo.exe
- From: Cliff Hones <cliff at hones dot org dot uk>
- To: Volker Quetschke <quetschke at scytek dot de>
- Cc: cygwin at cygwin dot com
- Date: Mon, 19 Dec 2005 15:22:54 +0000
- Subject: Re: test -e cannot distinguish between foo and foo.exe
- References: <43A6CDA0.8060508@scytek.de>
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/