"Matias A. Fonzo" <s...@dragora.org> writes: > On Mon, 14 Dec 2009 12:21:12 +0000 > Marc Herbert <marc.herb...@gmail.com> wrote: > >> Matias A. Fonzo a écrit : >> > On Fri, 11 Dec 2009 16:16:13 +0000 >> > Marc Herbert <marc.herb...@gmail.com> wrote: >> >> >> In case anyone is interested my winner (so far) is: >> >> >> >> exists() >> >> { >> >> [ -e "$1" -o -L "$1" ] >> >> } >> >> >> > >> >> > The -L is redundant. >> >> Not for me. I need -L because I want to consider broken symlinks just >> like anything else. A broken symlink would be a bug in my code and I want to >> detect it ASAP. >> >> >> > Because, if the symlink is not broken, the regular file "exists" ( -e ). >> >> Please forget about correct symlinks. The -L is here for *broken* >> symlinks. >> > > The [ -L "foo" -a ! -e "foo" ] is a specific case to check dangling symlinks.
Combine that with the existence check and you have exactly the expression above. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."