On 07/12/2012 10:23 AM, Stefano Lattarini wrote:

>> Other than that, the only supported method in existing POSIX for
>> checking for equal files is by parsing 'ls -i' output; but I don't know
>> if 'ls -i' is portable to ancient hosts.
>>
> I was fearing this would have got quickly complex and messy ...
> 
> So I think I'll stick to my dumber and safer "test -f /bin/RMDIR" as a
> way to detect case-insensible filesystems.

Assuming it was intentional, I like your re-wording of
"case-insensible", as an apt description of the pain case-insensitive
systems cause on portability :)

That said, /bin/RMDIR is probably completely portable, but seems like it
would be reliable in practice.  POSIX doesn't reqiure /bin/rmdir to
exist (about the only files that you can guarantee with POSIX are /tmp,
/dev/null, /dev/tty, and /dev/console).  Since /dev/ generally doesn't
exist on mingw, that almost limits you to just testing if /tmp and /TMP
are the same directory to detect a case-insensitive system.  But I don't
know of any systems that lack /bin/rmdir on a default installation, nor
do I suspect many users intentionally create /bin/RMDIR (or even better,
/bIn/rMdIr), so using it as a hueristic seems okay for a first cut at
the problem at hand.  Or, maybe you should just create a file in /tmp
under one spelling and check existence of the file by another spelling.

-- 
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org



Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to