]> git.armaanb.net Git - dmenu.git/blobdiff - dmenu_path
reverted setlocale() call
[dmenu.git] / dmenu_path
index f64c82e67093d3fce4039839a1992175f6ab4c63..7896a9e957fa1e274805c0641c841a6b82334667 100755 (executable)
@@ -1,9 +1,26 @@
 #!/bin/sh
+CACHE=$HOME/.dmenu_cache
 IFS=:
-for dir in $PATH
-do
-       for file in "$dir"/*
+
+uptodate() {
+       test -f "$CACHE" &&
+       for dir in $PATH
        do
-               test -x "$file" && echo "${file##*/}"
+               test ! $dir -nt "$CACHE" || return 1
        done
-done | sort | uniq
+}
+
+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"