Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ((Re: set -vx changes output of)) subshells



On Feb 9, 11:45pm, C. v. Stuckrad wrote:
} Subject: ((Re: set -vx changes output of)) subshells
}
} On Wed, 5 Feb 1997, Daniel Dignam wrote:
} >    My assumption was that the set -vx didn't get inherited by the
} > subshells, but my understanding would appear to be false, I guess $()
} > isn't really a subshell ...
} 
} Well, This reminds me of a question I never could get solved so far:
} 
} How, if it is at all possible, can a $(...) subshell or the inside of a
} construct 'know' that is not '*THE* interactive' shell ?

It is true that there is no guaranteed way to discover that you are in a
subshell.  However, both `monitor' and `zle' become unset when entering
a subshell, so if you normally set either of those, `[[ -o monitor ]]' or
`[[ -o zle ]]' will become false when you've entered a subshell.

Inside $(...), `[[ -t 1 ]]' will detect that the output isn't a terminal.

} Simple but irritating (for me) exammple:
} 
} Assume you make a function 'xswt' which sets Window titles in X11-Xterms.
} Then you include 'xswt' inside of chpwd, so it gets executed at every 'cd'

The solution to this *specific* problem is to put `xswt' in preprompt(),
not in chpwd().

You should probably test `[[ -t 1 ]]' in `xswt' even so, in case somebody
calls it directly.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern



Messages sorted by: Reverse Date, Date, Thread, Author