]> git.armaanb.net Git - dmenu.git/blobdiff - dmenu_path
applied Ramils patch
[dmenu.git] / dmenu_path
index 4ecf4faa957e6e15b3d90c92dfbb10c2e1e4d08a..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 -u
+}
+
+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"