On 31Jan2007 08:47, Daniel Qarras dqarras@yahoo.com wrote: | > A POSIX shell requires that the test command supports this: | > | > -h file | > True if file exists and is a symbolic link. | > -L file | > True if file exists and is a symbolic link. | | Thanks, I already saw those but initially they did not work for | directories. That was because I had | | dirs=[^.]*/ | | that would expand, e.g: | | foo/ | bar/ | | and the trailing slash caused -L test to fail.
Indeed, because it forces a test to be _not_ on the symlink but on what is on the far side of it.
BTW, if you've been following this thread you should know that:
[^.]*/
is better written:
*/
which means _exactly_ the same thing.
Of course, you realise that you may not need to test for -d at all because */ will only return directories (or things pointing at them). (Except when there are no directories at all - the it returns "*/" unchanged and you just need to test for existence.)
Cheers,