X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu_path;h=7896a9e957fa1e274805c0641c841a6b82334667;hb=c24f22a36bb986287f2b53116dff6479c434bc7d;hp=3070eb74944010eaa65588d58e69cc894635f2a8;hpb=5f436fdcb733cf9c669a0c94ad95878163f04b9a;p=dmenu.git diff --git a/dmenu_path b/dmenu_path index 3070eb7..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 }' | /usr/bin/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"