Hello,

Peter Hartlich --> dwm (2008-04-07 22:51:15 +0200):
[...]
> diff -r 612d48273009 dmenu_run
> --- a/dmenu_run       Thu Apr 03 21:56:19 2008 +0100
> +++ b/dmenu_run       Mon Apr 07 22:17:29 2008 +0200
> @@ -1,2 +1,2 @@
>  #!/bin/sh
> -exe=`dmenu_path | dmenu $*` && exec $exe
> +exe=`dmenu_path | dmenu "$@"` && exec $exe

Makes sense. I'd prefer

        exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe

though to make sure dmenu is not passed an empty argument in case
dmenu_run is called without arguments.


> diff -r 612d48273009 dmenu_path
> --- a/dmenu_path      Thu Apr 03 21:56:19 2008 +0100
> +++ b/dmenu_path      Mon Apr 07 22:17:24 2008 +0200
> @@ -3,24 +3,24 @@
>  IFS=:
>  
>  uptodate() {
> -     test ! -f $CACHE && return 1
> +     test -f "$CACHE" &&
>       for dir in $PATH
>       do
> -             test $dir -nt $CACHE && return 1
> +             test ! $dir -nt "$CACHE" || return 1
>       done
> -     return 0
>  }

Why? This is equivalent...


>  if ! uptodate
>  then
>       for dir in $PATH
>       do
> -             for file in "$dir"/*
> +             cd "$dir" &&
> +             for file in *
>               do
> -                     test -x "$file" && echo "${file##*/}"
> +                     test -x "$file" && echo "$file"
>               done

Hmm, for few directories and lots of files this is indeed slightly
faster.


> -     done | sort | uniq > $CACHE.$$
> -     mv $CACHE.$$ $CACHE
> +     done | sort -u > "$CACHE".$$ &&
> +     mv "$CACHE".$$ "$CACHE"
>  
> -cat $CACHE
> +cat "$CACHE"

Not all sort(1)s have a -u option. However, the '&&' is a good idea,
as is the quoting.


Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

Reply via email to