earle@jpl.nasa.GOV (Greg Earle) (07/20/89)
Normally I like to be able to use ^D (UNIX EOF) to kill/exit shells, so I don't set the `ignoreeof' csh/tcsh variable unless I'm in a login shell. I have checks in .cshrc to prevent this (I keep track of the shell depth via a variable). Now I want to do the same prevention for my shell running in my console xterm, namely set `ignoreeof' but only if it's the shell running in the console xterm that will kill the server if that particular shell is killed (e.g., if I'm in that shell and get a subshell via manually invoking `csh' or `tcsh', I want to turn `ignoreeof' off again, so I can ^D out of that one). My current method follows, but it's rather messy. Is there a better way to do this, like an X program that you can simply get the information out of that determines whether the current window you are in is, indeed, the console xterm (or login xterm or initial xterm, whichever term you want to use for the magic xterm that will bring down the world when you exit it). I realize this is implementation dependant, since I made the choice to exec my console xterm as the very last thing in my ~/.xinitrc ... if ($?WINDOWID) then if ($shelldepth == 2) then # make sure accidental ^D doesn't kill console xterm xprop -id $WINDOWID -notype | egrep WM_COMMAND | egrep '"-C' > /dev/null if ($status == 0) then set ignoreeof endif endif endif Disclaimer: Don't even THINK that my postings represent the company I work for. - Greg
rbj@DSYS.NCSL.NIST.GOV (Root Boy Jim) (07/20/89)
? From: earle@jpl.nasa.gov (Greg Earle) ? Normally I like to be able to use ^D (UNIX EOF) to kill/exit shells, so ? I don't set the `ignoreeof' csh/tcsh variable unless I'm in a login shell. ? I have checks in .cshrc to prevent this (I keep track of the shell depth ? via a variable). Well, I disagree violently on that point. Ignoreeof should always be set. But, it takes all kinds, so read on. They way to distinguish a `login shell' is by whether it sources .login. The `-ls' option to xterm is available for this purpose. Use it with the `-C' option on your console shell. Of course, all my xterms use this option, since I consider each window to be a separate login, so that doesn't help you if you do that. In any case, since you are using .xinitrc, and environment variables are inherited, just precede your console xterm with setenv IAmAnXLoginShellPleaseSetIgnoreeof Your .login (or .cshrc if you must) would contain if ($?IAmAnXLoginShellPleaseSetIgnoreeof) then set ignoreeof endif unsetenv IAmAnXLoginShellPleaseSetIgnoreeof Well, you probably should use a shorter name, but you get the idea. ? Disclaimer: Don't even THINK that my postings represent the company I work for. ? - Greg Root Boy Jim Have GNU, Will Travel.