On Sun, Jul 24, 2011 at 6:41 PM, lolilolicon <[email protected]> wrote:
> cmd=`dmenu "$@" < "$CACHE"` && eval exec "$cmd"
>
> NOTE:
> The (subshell) is used so the declarations won't get inherented, but
> the user still has access to the $CACHE and $cmd environments.
>

Hmm, maybe instead of `eval exec', we could just use `exec sh -c' instead?

  cmd=`dmenu "$@" < "$CACHE"` || exit $?
  exec sh -c "$cmd"

The benefits are:

1. Only exported environment variables will be available to the user command.
2. The user can run any shell command, including, e.g.,

  if true; then echo hello\ world; fi

Correct me if I'm missing something here. Thanks.

Reply via email to