X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu_path;h=7896a9e957fa1e274805c0641c841a6b82334667;hb=17232f493b07973bacd60abb2e957ccae829eb7e;hp=4008f4ce96f83cc5f4b1feeeaa5b2cb419f75ab4;hpb=a71424ac0e74f05274a8009f07487112730fa472;p=dmenu.git diff --git a/dmenu_path b/dmenu_path index 4008f4c..7896a9e 100755 --- a/dmenu_path +++ b/dmenu_path @@ -1,2 +1,26 @@ #!/bin/sh -/bin/ls -lL `echo $PATH | tr : ' '` 2> /dev/null | awk '$1 ~ /^[^d].*x/ { print $NF }' | sort -u +CACHE=$HOME/.dmenu_cache +IFS=: + +uptodate() { + test -f "$CACHE" && + for dir in $PATH + do + test ! $dir -nt "$CACHE" || return 1 + done +} + +if ! uptodate +then + for dir in $PATH + do + cd "$dir" && + for file in * + do + test -x "$file" && echo "$file" + done + done | sort | uniq > "$CACHE".$$ && + mv "$CACHE".$$ "$CACHE" +fi + +cat "$CACHE"