Mail Archives: djgpp-workers/2001/02/14/02:18:21
On Tue, 13 Feb 2001, Alain Magloire wrote:
> > > [if test -d ".\."; then
> > Are you sure this test works?
>
> Well if it did not work on DOS, Juan(?) could not have spotted the error.
>
> >Wouldn't that resolve to 'test -d ..' on any system?
>
> No, it will resolve to searching in the current directory "."
> for a directory call ".". Which can not be in Unix, "." and ".."
> always exist.
>
> hmm, I probably confuse you even more ... see it this way
> if you were looking for Unix file system as oppose to DOS file system
> you would have test for this:
> if test -d "./."; then
> # Unix file
>
> Better ?
No, because this test, when run on DOS, will tell you it's Unix ;-).
This is one of those, admittedly few, cases where DOS is ``smarter''
than Unix (for some value of ``smart''). DOS normalizes all file
names before passing them to the actual system call code. In
addition, DOS recognizes '/' as a valid directory separator in a file
name, together with '\'. The upshot of all this is that "./." gets
normalized to ".", and the test works.
> In any case credits go to Paul Eggert and Eli for this coocoo test ;-)
You are welcome.
- Raw text -