>>> empty_dir()
>>> { 
>>>     test "x$(echo $1/*$2)" = "x$1"'/*'"$2"
>>> }

pk wrote:
> This fails if the directory contains a file called "*". 

Yes. Unlike the ones below, empty_dir() above considers as empty a
directory that has a SINGLE element named '*'. Since I am not so
interested in files named '*', I think I can live with that!


Chris & others wrote:
>> is_file2()
>> { 
>>     for f
>>     do
>>         [ -e "$f" ] && return
>>     done
>>     return 1
>> }

I think I like this one.

Andreas:
> This will still fail if the first file happens to be a dangling symlink.

Yes, but I think it's valuable to refine "fail" again. Dangling symlinkS
(not just the first one) will be ignored, just like they were not
here. Some might find this acceptable.


For purists, does this one works even better?

is_file3()
{ 
    for f
    do
        [ -e "$f" -o -L "$f" ] && return
    done
    return 1
}



Thanks to everyone who answered, appreciated.



Reply via email to