[Xquartz-dev] 2.3.2_rc4

Cameron Simpson cs at zip.com.au
Mon Dec 22 17:27:51 PST 2008


Sorry all, I've been offline for a couple of days.

On 21Dec2008 23:59, Harald Hanche-Olsen <hanche at math.ntnu.no> wrote:
| + Martin Costabel <costabel at wanadoo.fr>:
| >  #!/bin/bash --login
| >  export cmd=$(dirname "$0")/X11.bin
| >  export args="${@}"
| >  exec -l "$SHELL" -c 'exec "$cmd" "$args"'
| 
| Or, as I indicated earlier, we could actually investigate $SHELL and
| do the appropriate thing depending on the value.

I'd be for this if we can't beat the quoting problem.

Meanwhile, here's a beefier single-script solution that:
  - handles arbitrary paths
  - runs only the user's login stuff and nothing extra
  - passes the subcommand, bash-quoted, through the envionment to itself for
    re-execing in bash i.e. in the same shell dialect
I need to do some more testing on it, but I think the approach is
pretty robust.

Here's the link:
  http://www.cskk.ezoshosting.com/cs/css/bin/with-login-env
Usage:
  with-login-env some-command [args...]

Harald, I'd be very obliged if you'd test this against rc and es
and critique it for quoting weaknesses. In particular, how does
rc/es think of this:

  'foo'\''bar'

for quoting foo'bar as a string?

| Here is my take (NB untested):
| 
| #!/bin/bash --login
| if [ -x ~/.x11-run ]; then exec ~/.x11-run "$@"; fi
| case "$SHELL" in
|   */bash)
|     exec "$@" ;;
|   */ksh | */sh | */zsh)
|     exec -l "$SHELL" -c 'exec "$@"' - "$@" ;;
|   */csh | */tcsh)
|     exec -l "$SHELL" -c 'exec $argv:q' "$@" ;;
|   */es | */rc)
|     exec "$SHELL" -l -c 'exec $*' "$@" ;;
|   *)
|     exec "$@" ;;
| esac

Depending how flexible with-login-env is, we could then reduce this case
statement to only the shells it doesn't handle.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/


More information about the Xquartz-dev mailing list