changeset: 204:908ab5d745f7
parent: 202:8d92d29eddd5
user: Kris Maglione <jg_AT_suckless.org>
date: Wed May 23 16:42:51 2007 -0400
summary: Changed dmenu_path (fixed race, improved speed, check that $PATH is the same as the last run).
diff -r a03cab6f38d6 -r 908ab5d745f7 dmenu_path
--- a/dmenu_path Wed May 23 22:32:43 2007 +0200
+++ b/dmenu_path Wed May 23 16:42:51 2007 -0400
@@ -1,25 +1,26 @@
-#!/bin/sh
+#!/bin/sh -f
CACHE=$HOME/.dmenu_cache
IFS=:
+qfind() {
+ find "$@" 2>/dev/null
+}
+
uptodate() {
- test ! -f $CACHE && return 1
- for dir in $PATH
- do
- test $dir -nt $CACHE && return 1
- done
- return 0
-}
+ test -f $CACHE &&
+ test "$(echo "$PATH")" = "$(sed 1q "$CACHE")" &&
+ qfind $PATH -maxdepth 0 -newer $CACHE
+}
if ! uptodate
then
- for dir in $PATH
- do
- for file in "$dir"/*
- do
- test -x "$file" && echo "${file##*/}"
- done
- done | sort | uniq > $CACHE
+ {
+ echo "$PATH"
+ qfind $PATH -type f -maxdepth 1 -perm -u+x -o -perm -g+x -o -perm -o+x |
+ sed 's,.*/,,' | sort | uniq
+ } > $CACHE.$pid
+ mv $CACHE.$pid $CACHE
fi
-cat $CACHE
+tail -n +2 $CACHE
+
diff -r a03cab6f38d6 -r 908ab5d745f7 main.c
--- a/main.c Wed May 23 22:32:43 2007 +0200
+++ b/main.c Wed May 23 16:42:51 2007 -0400
@@ -437,28 +437,28 @@ main(int argc, char *argv[]) {
/* command line args */
for(i = 1; i < argc; i++)
- if(!strcmp(argv[i], "-b")) {
+ if(!strncmp(argv[i], "-b", 3)) {
bottom = True;
}
- else if(!strcmp(argv[i], "-fn")) {
+ else if(!strncmp(argv[i], "-fn", 4)) {
if(++i < argc) font = argv[i];
}
- else if(!strcmp(argv[i], "-nb")) {
+ else if(!strncmp(argv[i], "-nb", 4)) {
if(++i < argc) normbg = argv[i];
}
- else if(!strcmp(argv[i], "-nf")) {
+ else if(!strncmp(argv[i], "-nf", 4)) {
if(++i < argc) normfg = argv[i];
}
- else if(!strcmp(argv[i], "-p")) {
+ else if(!strncmp(argv[i], "-p", 3)) {
if(++i < argc) prompt = argv[i];
}
- else if(!strcmp(argv[i], "-sb")) {
+ else if(!strncmp(argv[i], "-sb", 4)) {
if(++i < argc) selbg = argv[i];
}
- else if(!strcmp(argv[i], "-sf")) {
+ else if(!strncmp(argv[i], "-sf", 4)) {
if(++i < argc) selfg = argv[i];
}
- else if(!strcmp(argv[i], "-v"))
+ else if(!strncmp(argv[i], "-v", 3))
eprint("dmenu-"VERSION", © 2006-2007 Anselm R. Garbe, Sander van Dijk\n");
else
usage();
Received on Wed May 23 2007 - 22:44:22 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:47 UTC