Reuti wrote: > While we are on this: wondering about the difference about -h and -L I found > that `man test` outputs on OS X: > > " -h file True if file exists and is a symbolic link. This > operator is retained for compatibility with pre- > vious versions of this program. Do not rely on its > existence; use -L instead." > > while on Linux `man test` just states that it's the same. Is there any > preference which one should be used for the bash builtin?
Originally Unix did not provide symlinks. Then when symlinks were added they were not completely added in a uniform regular way through every command. Bummer! The original option letter used by test to check for the presence of a symlink was -h. I don't know why. But in those days the only test option to test for a symlink was -h. The -L came later. This legacy is still visible in the HP-UX test man page for example. No -L documented there. http://nixdoc.net/man-pages/HP-UX/man1/test.1.html However note that because POSIX requires it the /bin/sh posix shell must implement -L as identical to -h. And the reverse. Therefore you are safe to use either on any POSIX system. Remember too that POSIX wasn't originally meant as a design document but as an OS feature non-proliferation treaty to make it possible to write portable programs. POSIX features must be present on any POSIX system and therefore you can use the feature and expect it to work. If you need to interact with legacy systems which predate POSIX and have never been updated to comply then you must use -h because that is all there is there. But if you never interact with anything non-POSIX then using -L is okay too. Either is the same as the other now. I think the statement in the Apple man page is there because someone liked -L over -h and wanted to scare everyone into using one over the other. But there isn't any reason to do so. Bob