From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id AAA14244 for ; Tue, 17 Sep 1996 00:52:06 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA16075; Mon, 16 Sep 1996 10:40:17 -0400 (EDT) Resent-Date: Mon, 16 Sep 1996 10:36:26 -0400 (EDT) From: "Bart Schaefer" Message-Id: <960916000753.ZM1100@candle.brasslantern.com> Date: Mon, 16 Sep 1996 00:07:53 -0700 In-Reply-To: "C. v. Stuckrad" "HOW TO distiguish between command input and forked subshell ?" (Sep 7, 6:30pm) References: Reply-To: schaefer@nbn.com X-Face: #Fj,SD!uGM$mK+=c."{GSa.kjFfFet4[=3Bwr{5@oO*TuJEP3=}'%qRL$bP#~s|yS9JO1v+ &XeZy#u7!sml79&(,L$Q:/2(2?b, zsh-users@math.gatech.edu Subject: Re: HOW TO distiguish between command input and forked subshell ? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"8XCae2.0.0w3.gNMFo"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/406 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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"