[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: best way to test for empty dir?
From: |
Matias A. Fonzo |
Subject: |
Re: best way to test for empty dir? |
Date: |
Mon, 14 Dec 2009 15:30:51 -0200 |
On Mon, 14 Dec 2009 12:21:12 +0000
Marc Herbert <Marc.Herbert@gmail.com> wrote:
> Matias A. Fonzo a écrit :
> > On Fri, 11 Dec 2009 16:16:13 +0000
> > Marc Herbert <Marc.Herbert@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.
>
> > A solution to check the broken symlink is:
> >
> > [ -e "foo" -o -L "foo" -a ! -e "foo" ]
>
> For which type of "foo" object does this return a different value than
> the above? None.
>
Is just an example.
> If common sense is not enough, here is a formal proof that your third
> and last test is redundant:
>
> -e or (-L and ! -e) == (-e or -L) and (-e or ! -e) distributivity
> (-e or -L) and 1 complements
> -e or -L boundedness
>
> <http://en.wikipedia.org/wiki/Boolean_logic#Properties>
>
Yeah logic.. I have intuition.
Regards,
Matías
- Re: best way to test for empty dir?, (continued)
- Message not available
- Re: best way to test for empty dir?, pk, 2009/12/11
- Re: best way to test for empty dir?, Sven Mascheck, 2009/12/11
- Re: best way to test for empty dir?, Chris F.A. Johnson, 2009/12/11
- Re: best way to test for empty dir?, Sven Mascheck, 2009/12/11
- Re: best way to test for empty dir?, Marc Herbert, 2009/12/11
- Re: best way to test for empty dir?, Greg Wooledge, 2009/12/11
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/11
- Re: best way to test for empty dir?, Andreas Schwab, 2009/12/12
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/12
- Re: best way to test for empty dir?, Marc Herbert, 2009/12/14
- Re: best way to test for empty dir?,
Matias A. Fonzo <=
- Re: best way to test for empty dir?, Andreas Schwab, 2009/12/15
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/15
- Re: best way to test for empty dir?, Andreas Schwab, 2009/12/15
- Re: best way to test for empty dir?, Matias A. Fonzo, 2009/12/15
- Message not available
- Re: best way to test for empty dir?, Antonio Macchi, 2009/12/15
- Message not available
- Re: best way to test for empty dir?, Stephane CHAZELAS, 2009/12/12
- Re: best way to test for empty dir?, Stephane CHAZELAS, 2009/12/12
Message not available
Message not available