zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "C. v. Stuckrad" <stucki@math.fu-berlin.de>, zsh-users@math.gatech.edu
Subject: Re: HOW TO distiguish between command input and forked subshell ?
Date: Mon, 16 Sep 1996 00:07:53 -0700	[thread overview]
Message-ID: <960916000753.ZM1100@candle.brasslantern.com> (raw)
In-Reply-To: "C. v. Stuckrad" <stucki@math.fu-berlin.de> "HOW TO distiguish between command input and forked subshell ?" (Sep  7,  6:30pm)

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"


      reply	other threads:[~1996-09-16 14:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <960905162314.ZM11373@admin.diego.netmanage.com>
1996-09-07 16:30 ` C. v. Stuckrad
1996-09-16  7:07   ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=960916000753.ZM1100@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=schaefer@nbn.com \
    --cc=stucki@math.fu-berlin.de \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).