delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/06/18/14:05:19

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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
q=dns; s=default; b=CXXxkxSa65Tib6w7jGeP2bZ1SF3CDz06iyn0eqbyRf/
SASna+Lkf+wpPTeAjSA5nSJLR0qXZ25N6exyFCpGsbeMCbDZ0th4g6dUva9+FNga
zDkPld/7vUjxlGb8BSrl5yRk7Rqxnw5B3UUukmWthRAPLCVyNPdpccf2IpfjtLkk
=
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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
s=default; bh=ARxob5BXO/Zq6Dqsn12P61jERls=; b=mS+fnCHquKrZm6Wpv
686nehqPyAH35hI1pg3q7fWCh+TOsWP4heUH/dlaSBbzfJE2E1LOIe4pE4FSYcFK
nDU95W/ogD5AVyXz8w/J1hJY8qF+6L6CVMTmtNNkmPhEM8YTZPbMdKrMyPnUhIO8
+zC6A4a8uz1r0uq13MVPLDbZzw=
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-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-oa0-f47.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=VmOnXEo+Rs+1rt9Js3cxek1DSkKDyIgmkWz+m/3iWBQ=; b=MRVCalRhFUvfvaLVZfgCUMVkwQWV2VyNhBLIv+1DyLf+uqEETw+u/9oH4TPjAzokqI Q26hmHZCQEtRPWM5YpRnSMmUoMwXg2By8VLmLpKZxBBMAF2cRRXLkyStnyxIPPx+DeUj dHRVj0A3HKPyJ+YK1NXB9io+vOzBkh70JTJIKW4uneYj6o/JBvrExF+NayY5zYZiSwbF p1HB9uMQVle5OrNkRKW9+hhhcdwE76xt7hh+FA8OjQbywFTwc2LADVIqjgwOe47Pr+Vm uhAKaMc7DKgcr8+766pXzfpvNHxvk7KZFCwU48G1rQUPvtprdQXOWhFpIgMY6Dkqcyhm MeBQ==
X-Gm-Message-State: ALoCoQmLEe7rrq3kpjVZ2iV2GomM2IhJVvHPY8SfnQkqp352PfuKE8ZwcMxazFwZT0lK3bEf/a0o
X-Received: by 10.60.146.210 with SMTP id te18mr3689227oeb.44.1403114673723; Wed, 18 Jun 2014 11:04:33 -0700 (PDT)
Message-ID: <53A1D4AC.2030104@breisch.org>
Date: Wed, 18 Jun 2014 14:04:28 -0400
From: "Chris J. Breisch" <chris DOT ml AT breisch DOT org>
User-Agent: Postbox 3.0.11 (Windows/20140602)
MIME-Version: 1.0
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: How to strictly differentiate <file>.exe with <file> ???
References: <1403111974 DOT 43795 DOT YahooMailNeo AT web172703 DOT mail DOT ir2 DOT yahoo DOT com>
In-Reply-To: <1403111974.43795.YahooMailNeo@web172703.mail.ir2.yahoo.com>
X-IsSubscribed: yes

Emmanuel Lepavec wrote:
> Hello,
>
> I have an issue with the latest version of Cygwin (previously I was using an old one 1.5.25, I think...).
> When using basic commands such as 'ls', 'rm', now the shell resolve incorrectly filenames without extension.
> If a same file with '.exe' extension exists, it will be used.
>
> For example, take a directory with a single file 'a.exe'.
> $ ls -a
> .  ..  bar.exe
> $ ls bar
> bar
> $ rm bar
> rm: remove regular empty file `bar'?
>
> The command should have returned 'rm: cannot remove `bar': No such file or directory'
>
> If I want to delete only 'bar' (without extension), it will actually delete 'bar.exe' file. This is an unexpected behavior which pose an big issue in some of my build scripts.
>
> Is there some way to strictly differentiate 'bar' from 'bar.exe'?
>
> Thank you.
>

I'm no expert, but...


If you actually have both a 'bar' and a 'bar.exe', then 'rm bar' will 
remove 'bar' and not 'bar.exe'. So, it seems to me that the problem is 
detecting when 'bar' is really 'bar.exe'.

On my machine, with a single file bar.exe, I can do this:

$ ls -i bar bar.exe
5348024558398844 bar  5348024558398844 bar.exe

Notice that they have the same pseudo-inode number. This would not be 
the case if they were distinct files. It shouldn't be hard to work up a 
little bash script that can let you know if bar is actually bar.exe.

Here's a sample I whipped up. This isn't bullet-proof and has some 
redundancy, but it's just a sample.

$ cat > areFilesSame.sh << EOF
#!/bin/bash
file1=$1
file2=$1.exe
inode1=$(ls -i $file1 | sed -e 's/ .*//')
inode2=$(ls -i $file2 | sed -e 's/ .*//')
if [ $inode1 -eq $inode2 ]; then
    echo $file1 is actually $file2
else
    echo $file1 and $file2 are separate files
fi
EOF

$ chmod +x areFilesSame.sh

$ ./areFilesSame.sh bar
bar is actually bar.exe


-- 
Chris J. Breisch

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