Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!uwvax!margay.cs.wisc.edu!dws From: dws@margay.cs.wisc.edu (DaviD W. Sanderson) Newsgroups: comp.windows.x Subject: Re: Those Wacky .xsession files Message-ID: <1991Feb16.013704.21679@spool.cs.wisc.edu> Date: 16 Feb 91 01:37:04 GMT References: <9102132312.AA19002@jupiter.saic.com> <9102141614.AA03702@iris49.biosym.com> Sender: news@spool.cs.wisc.edu (The News) Distribution: na Organization: U of Wisconsin CS Dept Lines: 66 In article <9102141614.AA03702@iris49.biosym.com> pete@iris49.UUCP (Pete Ware) writes: >My second guess is that your shell script is getting executing by the >csh because: [...] > 2. xdm is doing something like "/bin/csh -c $HOME/.xsession" > and it's getting read as a csh script. You can see exactly how it's being run by finding the xdm configuration files. For instance, on my workstation the script that xdm runs is /usr/misc/X11/lib/xdm/Xsession. Down towards the end it checks if there is a $HOME/.xsession file and if so, does this: exec /bin/csh $HOME/.xsession In order to get around this problem, I devised the following prologue for my .xsession file that may come in handy for others, too. ---------------------------------------------------------------------- #!/bin/sh #------- # .xsession prologue # # This prologue makes sure the subsequent code is run in sh, or ksh if # it is present. It is written to work in csh, sh, and ksh. Specific # pathnames may have to be altered (or added) if your ksh isn't in /bin. # # This prologue is needed since in some installations the .xsession file # is forcibly run with csh or sh. # # DaviD W. Sanderson 15 Feb 1991 (dws@cs.wisc.edu) #------- #------- # If the script is now being executed by csh, look for ksh and try to # exec it. Otherwise exec sh. Note that test -x cannot be used since # some versions of test do not support the -x option. :-( # # The method used is to look for variables that should only be set in # csh. This is not perfectly bulletproof, but works well enough for me. #------- test "$cwd" != "" && test -f /bin/ksh && exec /bin/ksh $0 $argv:q test "$cwd" != "" && exec /bin/sh $0 $argv:q #------- # At this point the script is being executed by either sh or ksh. # # We might have gotten here from sh in the first place (if perhaps the # .xsession was forcibly run with sh), so see if we are in sh. # If we are, then see if ksh exists and exec it if it does. # # The method used is to look for ~ expansion. No ~ expansion means sh. #------- test "~" = ~ && test -f /bin/ksh && exec /bin/ksh $0 ${1+"$@"} #------- # At this point the script is being executed by ksh if it is available, # otherwise sh. #------- # [local configuration] ---------------------------------------------------------------------- -- ___ / __\ U N S H I N E DaviD W. Sanderson | | | I N E dws@cs.wisc.edu _____| | |_____ ________ \ / \ |__/ /////__ Fusion Powered Locomotives Made to Order \____/ \__|_/ \\\\\______ (TARDIS model available at extra cost)