Jukka Salmi --> dwm (2007-05-23 10:53:21 +0200):
> Frank Pirnay --> dwm (2007-05-23 09:16:45 +0200):
> > I thought about broken hardware too... I will try some memtesting today.
> 
> That's probably a good idea.
> 
> 
> > Anyway, this is my output:
> > 
> > + CACHE=/home/knarf/.dmenu_cache
> > + UPTODATE=1
> > + IFS=:
> > + test ! -f /home/knarf/.dmenu_cache
> > + test 1
> > + test /home/knarf/bin -nt /home/knarf/.dmenu_cache
> > + test /usr/local/sbin -nt /home/knarf/.dmenu_cache
> > + test /usr/local/bin -nt /home/knarf/.dmenu_cache
> > + unset UPTODATE
> > + test /usr/sbin -nt /home/knarf/.dmenu_cache
> > + test /usr/bin -nt /home/knarf/.dmenu_cache
> > + unset UPTODATE
> > + test /sbin -nt /home/knarf/.dmenu_cache
> > + test /bin -nt /home/knarf/.dmenu_cache
> > + unset UPTODATE
> > + test /usr/games -nt /home/knarf/.dmenu_cache
> > + test !
> > Segmentation fault
> > 
> > The segfault always happens at this place. Any ideas?
> 
> What is /bin/sh on that system? In case it a symlink to /bin/bash:
> what bash version is this? If it's another shell: what test(1) is it
> using, e.g. a shell builtin or an external command?
> 
> Try replacing line 19 of dmenu_path with
> 
>       if test -n $UPTODATE
> 
> In case the segfault still occurs, try quoting $UPTODATE on line 19,
> i.e.
> 
>       if test ! "$UPTODATE"
> 
> or
> 
>       if test -n "$UPTODATE"
> 
> Does any of this help?

I'm able to reproduce this problem with a bourne shell on some BSD
systems; it seems to be a bug in the test(1) code. Maybe you were
bitten by the same bug.

To make dmenu_path more robust against such problems I'd recommend the
attached patch. Furthermore it speeds up execution time a little bit
in case the cache has to be rebuilt because of a changed directory
(unless it the last directory in the $PATH).


Regards, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
diff -r d14fe4d89e3f dmenu_path
--- a/dmenu_path        Mon May 21 14:36:03 2007 +0200
+++ b/dmenu_path        Wed May 23 12:42:44 2007 +0200
@@ -3,20 +3,22 @@ UPTODATE=1
 UPTODATE=1
 IFS=:
 
+uptodate() { [ $UPTODATE -eq 1 ]; }
+
 if test ! -f $CACHE 
 then
-       unset UPTODATE
+       UPTODATE=0
 fi
 
-if test $UPTODATE
+if uptodate
 then
        for dir in $PATH
        do
-               test $dir -nt $CACHE && unset UPTODATE
+               test $dir -nt $CACHE && { UPTODATE=0; break; }
        done
 fi
 
-if test ! $UPTODATE
+if ! uptodate
 then
        for dir in $PATH
        do

Reply via email to