Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewse!cbnewsd!cbfsb!cbnewsc!lied From: lied@cbnewsc.att.com (Bob Lied) Newsgroups: comp.sys.3b1 Subject: Re: stty: : Not a typewriter (really ksh $ENV file) Keywords: vi, ksh Message-ID: <1991Mar8.154644.9039@cbnewsc.att.com> Date: 8 Mar 91 15:46:44 GMT References: <1495@das13.snide.com> <1496@das13.snide.com> <1991Mar7.130721.4475@dms3b1.uucp> Organization: AT&T Bell Laboratories Lines: 30 In answer to the question of how to avoid interactive stuff in a ksh $ENV file, especially for things like editor escapes, there are two common solutions that I know of: 1. The $- variable lists the flags that are set by ksh. If ksh is invoked interactively (which I believe translates to input and output are ttys), then the -i flag is set. So, one way to avoid things that write to the terminal for non-interactive use is something like this inside the $ENV file: case "$-" in *i*) # stty, reset prompts, alias cd, etc ;; *) # functions and aliases that always export esac 2. To avoid having the $ENV file sourced at all, there is a trick that comes from page 78 of "The Kornshell Command and Programming "Language". Instead of setting ENV directly, you set a secondary variable and use a side effect of evaluation (ENV is always re-evaluated at shell startup). So, in the .profile, you set up something like: export ENVFILE=~/.kshrc export ENV='${ENVFILE[(_$-=0)+(_=1)-_${-%%*i*}]}' Note that the last part of this is the same as above: checking $- to see if the -i flag is set. The rest of the gobbledygood evaluates to 0 or 1; if it's zero, ENV == ENVFILE, but if it's one, ENV=''. No one said it had to be obvious. Bob Lied att!ihlpf!lied