[Xquartz-dev] 2.3.2_rc4

Martin Costabel costabel at wanadoo.fr
Thu Dec 18 15:37:06 PST 2008


Jeremy Huddleston wrote:
> 
> Would someone who uses tcsh give me an example ~/.x11run that I can 
> place in the FAQ here:
> 
> http://xquartz.macosforge.org/trac/wiki/X11-UsersFAQ#Howcanmylauncedapplicationsinheritmytcshenvironment 
[]
>> I wonder if it would be worthwhile turning that little script into 
>> something along the lines of
>>
>> #!/bin/bash --login
>>
>> if [ -x ~/.x11run ]; then
>> exec ~/.x11run "$(dirname $0)"/X11.bin "${@}"
>> else
>> exec "$(dirname $0)"/X11.bin "${@}"
>> fi

I think the following works (does for me, anyway, but I haven\t tested 
it extensively):

#!/bin/sh
/usr/bin/login -pqf $USER <<EOF
   $*
EOF

Note that this does not talk about tcsh, but it uses csh syntax. It uses 
tcsh if tcsh is the $USER's login shell. It could also be written 
completely $SHELL neutrally as

#!/bin/sh
cmdline="${@}"
/usr/bin/login -pqf $USER <<EOF
   $cmdline
EOF

This will again work with tcsh as login shell, but not with bash.
("work" meaning that the login startup shell scripts are run).

This whole mess is caused by the fact that /usr/bin/login does not, as 
it claims, systematically start login shells. It does so for tcsh, but 
it doesn't for bash. For bash, one needs to run explicitly `bash 
--login`, as you are now doing. Even for tcsh, one needs to use the 
"here-doc" trick; simply running

/usr/bin/login -pqf $USER $cmdline

will *not* read the startup scripts.

I wonder how Terminal.app is doing this. After all, it manages to start 
a login shell for everybody.

-- 
Martin



More information about the Xquartz-dev mailing list