On 07/24/11 at 01:34am, Dave Reisner wrote:
> #!/bin/sh
> 
> CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
> IFS=:
> LC_COLLLATE=C
You got a typo here: LC_COLLATE

> 
> gencache() {
>   lsx $PATH | sort -u >"$CACHE"
> }
Since LC_COLLATE is only used for sort, we might as well just use:

  LC_COLLATE=C sort

> 
> if [ ! -e "$CACHE" ]; then
>   mkdir -p "${CACHE%/*}"
>   gencache
> fi
> 
> for path in $PATH; do
>   if [ "$path" -nt "$CACHE" ]; then
>     gencache
>     break
>   fi
> done
Much better than `ls -t', congratulations.
If $CACHE does not exist, there's no need to compare timestamps, so
let's puts an `else' there.

> unset IFS
> 
> cmd=$(dmenu "$@" < "$CACHE") && eval exec "$cmd"
Yeah, I see you just hate backticks :P

Reply via email to