[dev] [dmenu] dmenu_run improvements

From: lolilolicon <lolilolicon_AT_gmail.com>
Date: Sun, 24 Jul 2011 12:35:19 +0800

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.

`LC_ALL=C' is for sort.

diff -up a/dmenu_run b/dmenu_run
--- a/dmenu_run 1970-01-01 00:00:00.000000000 +0000
+++ b/dmenu_run 1970-01-01 00:00:00.000000000 +0000
@@ -1,9 +1,9 @@
 #!/bin/sh
 CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
 (
- IFS=:
+ IFS=: LC_ALL=C
         if test "`ls -dt $PATH "$CACHE" 2> /dev/null | sed 1q`" != "$CACHE"; then
                 mkdir -p "`dirname "$CACHE"`" && lsx $PATH | sort -u > "$CACHE"
         fi
 )
-cmd=`dmenu "$@" < "$CACHE"` && exec $cmd
+cmd=`dmenu "$@" < "$CACHE"` && eval exec "$cmd"
Received on Sun Jul 24 2011 - 06:35:19 CEST

This archive was generated by hypermail 2.2.0 : Sun Jul 24 2011 - 06:36:03 CEST