* HOW TO distiguish between command input and forked subshell ? [not found] <960905162314.ZM11373@admin.diego.netmanage.com> @ 1996-09-07 16:30 ` C. v. Stuckrad 1996-09-16 7:07 ` Bart Schaefer 0 siblings, 1 reply; 2+ messages in thread From: C. v. Stuckrad @ 1996-09-07 16:30 UTC (permalink / raw) To: zsh-users On Thu, 5 Sep 1996, Bart Schaefer ANSWERED: > Subject: Re: HOW TO distiguish between command input and forked subshell ? > On Sep 6, 12:47am, C. v. Stuckrad ASKED: > > Subject: HOW TO distiguish between command input and forked subshell ? > > Exactly, I want to have the function 'chpwd' give some output > > if triggered by 'cd' or 'chdir' BUT TO GIVE NO OUTPUT > > if triggered by cases like '... $(cd somewhere; ls)...' *** this was exactly enough specified *** > chpwd() { > if [[ -t 1 ]] > then > print By golly, my standard output is a terminal. > fi > } OK, thanks for explaining (again), and this works perfectly well in this case of ... $(cd ...)... ! The User who aked was a typical beginner, who used a macro/function chpwd () { ...to change x-window-title to the current dir... } and now the title is no longer changed by cd-ing inside of $() expansions. BUT if you just type '(cd somwhere; do_something)' you again get the title changed to 'somewhere' instead of staying where the zsh stood and stayed ! Does somebody see a chance to distinguish the two cases ? I first thought $SHLVL, but it stays the same! Does ...; ( something ) ; ... the same as ... { something } ; ... ??? Again clueless (this time on zsh-users :-) Stucki Christoph von Stuckrad * * | talk to | <stucki@math.fu-berlin.de> \ Freie Universitaet Berlin |/_* | nickname | ...!unido!fub!leibniz!stucki| Fachbereich Mathematik, EDV |\ * | 'stucki' | Tel:+49 30 838-7545{9|8} | Arnimallee 2-6/14195 Berlin * * | on IRC | Fax:+49 30 838-5913 / ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: HOW TO distiguish between command input and forked subshell ? 1996-09-07 16:30 ` HOW TO distiguish between command input and forked subshell ? C. v. Stuckrad @ 1996-09-16 7:07 ` Bart Schaefer 0 siblings, 0 replies; 2+ messages in thread From: Bart Schaefer @ 1996-09-16 7:07 UTC (permalink / raw) To: C. v. Stuckrad, zsh-users On Sep 7, 6:30pm, C. v. Stuckrad wrote: } Subject: HOW TO distiguish between command input and forked subshell ? } } The User who aked was a typical beginner, who used a macro/function } chpwd () { ...to change x-window-title to the current dir... } } and now the title is no longer changed by cd-ing inside of $() } expansions. BUT if you just type '(cd somwhere; do_something)' } you again get the title changed to 'somewhere' instead of staying } where the zsh stood and stayed ! Don't change the title bar in chpwd(). Change the title bar in precmd(). If you want to avoid changing it "too frequently" for some reason, use if [[ ${oldPWD:=.} != $PWD ]] then # ... change title bar and ... oldPWD=$PWD fi } Does somebody see a chance to distinguish the two cases ? } I first thought $SHLVL, but it stays the same! In older Bourne shells you used to be able to distinguish by using foo=$$; (if [ $$ -ne $foo ] ... ; ) because $$ would change inside the subshell. But zsh doesn't do a new getpid() for every $$ reference, so that doesn't work. (This causes other problems, because you used to be able to have a subshell kill itself with `kill -1 $$` but in zsh that kills the parent.) I don't know of any way to detect subshell-ness, having played with it a bit in the past. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.nbn.com/people/lantern New male in /home/schaefer: >N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday" ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-09-16 14:52 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <960905162314.ZM11373@admin.diego.netmanage.com> 1996-09-07 16:30 ` HOW TO distiguish between command input and forked subshell ? C. v. Stuckrad 1996-09-16 7:07 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).