X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu_path;h=a9ddd473aa7239fc0cdc3e9b8c33f66d958881d0;hb=a7aee433ccfd2590e0785a7b93a89d8d0593a234;hp=4008f4ce96f83cc5f4b1feeeaa5b2cb419f75ab4;hpb=a71424ac0e74f05274a8009f07487112730fa472;p=dmenu.git diff --git a/dmenu_path b/dmenu_path index 4008f4c..a9ddd47 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 -u > "$CACHE".$$ && + mv "$CACHE".$$ "$CACHE" +fi + +cat "$CACHE"