On Wed, May 23, 2007 at 01:42:58PM +0200, Premysl anydot Hruby wrote:
> 2007/5/23, Anselm R. Garbe <[EMAIL PROTECTED]>:
> >
> >Thanks! I applied it to the repo, however I'm not totally sure
> >the use of [ is a good idea. Is [ a symlink to test in any Unix?
> >
> >Regards,
> >--
> >Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
> >
> >
> 
> 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.

Many thanks for this idea. I changed it that way.

Regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361

Reply via email to