* How to strictly differentiate <file>.exe with <file> ???
@ 2014-06-18 17:22 Emmanuel Lepavec
2014-06-18 18:04 ` Chris J. Breisch
0 siblings, 1 reply; 2+ messages in thread
From: Emmanuel Lepavec @ 2014-06-18 17:22 UTC (permalink / raw)
To: cygwin
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.
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to strictly differentiate <file>.exe with <file> ???
2014-06-18 17:22 How to strictly differentiate <file>.exe with <file> ??? Emmanuel Lepavec
@ 2014-06-18 18:04 ` Chris J. Breisch
0 siblings, 0 replies; 2+ messages in thread
From: Chris J. Breisch @ 2014-06-18 18:04 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-18 18:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 17:22 How to strictly differentiate <file>.exe with <file> ??? Emmanuel Lepavec
2014-06-18 18:04 ` Chris J. Breisch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).