[php-maint] Bug#626640: Bug#626640: Small optimization

Bob Proulx bob at proulx.com
Mon May 16 18:11:18 UTC 2011


Ondřej Surý wrote:
> Marcus Cobden wrote:
> > Here's (what I hope is) a small optimisation to Bob's solution.
>
> Hmm, that looks like a nice optimization. Bob, what do you think?

Two ways of doing this under discussion:

  a)   -execdir sh -c 'test -z "$(fuser "$0")"' {} \;

  b)   ! -execdir fuser -s {} \;

Certainly option b is prettier!  I like it and wish I had suggested
it.  :-)  Let me analyze the behavior of the two methods.

  File is busy case:

    fuser produces no output to stderr
    fuser produces output to stdout ; Option a) would not invoke -delete
    fuser exits 0                   ; Option b) would not invoke -delete

  File is not busy case:

    fuser produces no output to stderr
    fuser produces no output to stdout ; Option a) would invoke -delete
    fuser exits 1                      ; Option b) would invoke -delete

  An error occurs case:

    fuser produces output to stderr
    (If fuser errors then -delete might error too and find will emit
    output to stderr in this case too.)
    fuser produces no output to stdout ; Option a) would invoke -delete
    fuser exits 1                      ; Option b) would invoke -delete

Everything seems equivalent.  With option b much prettier I vote for
the option b suggestion from Marcus.

Thanks Marcus for jumping in with that suggestion!

Bob





More information about the pkg-php-maint mailing list