[Xquartz-dev] 2.3.2_rc4

Cameron Simpson cs at zip.com.au
Fri Dec 26 14:12:37 PST 2008


On 26Dec2008 16:04, Martin Costabel <costabel at wanadoo.fr> wrote:
> Harald Hanche-Olsen wrote:
>> Uh, sorry, there was one more thing ... if a former bash user has
>> converted to another shell, and still has his bash login stuff lying
>> around, it will be run in addition to the other shell's login files. I
>> think that is wrong. Therefore I believe this version is better:
>>
>> #!/bin/sh
>>
>> set "$(dirname "$0")"/X11.bin "${@}"
>>
>> if [ -x ~/.x11run ]; then
>> 	exec ~/.x11run "${@}"
>> fi
>>
>> case $(basename "${SHELL}") in
>> 	bash)         exec    "${SHELL}" --login -c 'exec "${@}"' - "${@}" ;;
>> 	ksh|sh|zsh)   exec -l "${SHELL}" -c 'exec "${@}"' - "${@}" ;;
>> 	csh|tcsh)     exec -l "${SHELL}" -c 'exec $argv:q' "${@}" ;;
>> 	es|rc)        exec -l "${SHELL}" -c 'exec $*' "${@}" ;;
>> 	*)            exec    "${@}" ;;
>> esac
>
> Looks good to me.

And also to me. Nearly.

Fairly importantly, the:

  #!/bin/sh

line needs to be:

  #!/bin/bash

because we're using the bash-specific "exec -l".

And I would still like to exec my generic script in the "*)" clause.
I believe we should at least try to run login stuff for "unknown"
shells using the generic mechanisms, while keeping the direct methods
above for efficiency and clarity reasons.

In fact, I've copied the whole case statement into my generic script,
which makes it more efficient in standalone use and lets you strip this
wrapper down further, should you wish. It would let the wrapper be an
"if" statement, clearer in its purpose.

A minor question: why "${@}" instead of "$@" ? And why "${SHELL}"
instead of "$SHELL"?

And we should put a usage message and abort at the top if there are no
arguments i.e. no command supplied:

  if [ $# = 0 ]
  then
    echo "Usage: $0 command [args...]" >&2
    exit 2
  fi

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

You do get used to it.  It still sucks.
        - Universal Peeve Mantra, 242 lbs before cooking


More information about the Xquartz-dev mailing list