As the title says, I'm looking for the most dependable way to detect whether a file-system is case sensitive or not, provided a given path.
In the past I've used the following dirty trick:
[ -e "/tmp" -a -e "/Tmp" ] && echo "Case insensitive" || echo "Case sensitive"
Which works because a system won't typically have both a /tmp
and a /Tmp
folder. This of course is hacky at best, and of no-use for arbitrary paths as it could be pointing to a device without either folder.
What I was thinking instead was doing something like getting a path's directory (which should exist) and somehow "flipping" its case (so upper case letters become lower case and vice versa), but I'm not sure how to do that either; I can flip all lower to upper, but that won't be any use if the directory's name is already all uppercase.
Anyway, I'm looking for suggestions on the best way to detect if a file-system is case sensitive or not, preferably without creating temporary files if possible.