On Sun, Jul 24, 2011 at 4:39 PM, Anselm R Garbe <garb...@gmail.com> wrote: > On 24 July 2011 06:34, Dave Reisner <d...@falconindy.com> wrote: >> On Sun, Jul 24, 2011 at 12:35:19PM +0800, lolilolicon wrote: >>> dmenu_run doesn't really run the user input as a shell command line. >>> For instance, run dmenu_run from a terminal, then in the menu type: >>> >>> echo hello\ world >>> >>> The terminal output is "hello\ world" instead of "hello world". >>> >>> `eval' solves the problem, but when it comes to eval, I can't really >>> be sure, so please point out the possible errors/risks. >> >> Assuredly the least of the evils in this script -- the eval is >> necessary. More noteworthy is the parsing of ls here, which can easily >> be refactored out and still be /bin/sh compat. It also explodes on first >> run, and then there's the needless invocation of mkdir every time the >> cache is regenerated. suckless could suck a lot less at shell scripting. >> dmenu_run has gone through several iterations of bad and worse. >> >> d >> >> >> #!/bin/sh >> >> CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run >> IFS=: >> LC_COLLLATE=C >> >> gencache() { >> lsx $PATH | sort -u >"$CACHE" >> } >> >> if [ ! -e "$CACHE" ]; then >> mkdir -p "${CACHE%/*}" >> gencache >> fi >> >> for path in $PATH; do >> if [ "$path" -nt "$CACHE" ]; then >> gencache >> break >> fi >> done > > Am I right that the previous loop runs gencache n times, under the > assumption that each path component contains newer files? > > Kind regards, > Anselm > >
No, note the `break'.