Premysl anydot Hruby --> dwm (2007-05-23 13:42:58 +0200): > So, if functions are allowed then maybe even better can be this: > > ======== > --- a/dmenu_path Wed May 23 13:22:27 2007 +0200 > +++ b/dmenu_path Wed May 23 13:37:33 2007 +0200 > @@ -1,22 +1,16 @@ > #!/bin/sh > CACHE=$HOME/.dmenu_cache > -UPTODATE=1 > IFS=: > > -uptodate() { [ $UPTODATE -eq 1 ]; } > - > -if test ! -f $CACHE > -then > - UPTODATE=0 > -fi > - > -if uptodate > -then > +uptodate() { > + test ! -f $CACHE && return 1 > for dir in $PATH > do > - test $dir -nt $CACHE && { UPTODATE=0; break; } > + test $dir -nt $CACHE && return 1 > done > -fi > + > + return 0 > +} > > if ! uptodate > then > ======== > > > Which throws decision about cache freshnes to the uptodate() func.
Yes, that's probably cleaner as long as uptodate() is only called once. Regards, Jukka -- bashian roulette: $ ((RANDOM%6)) || rm -rf ~