Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Request: a way to get the subshell level nesting
- X-seq: zsh-workers 25620
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Request: a way to get the subshell level nesting
- Date: Fri, 5 Sep 2008 10:11:45 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=/GvIOU1i8Exwuf8Vzd7hjPOga9YvPb0zKWzTCxhSMyk=; b=sJY03x1XmQt/ohzFbkK5Xu5083AKKLD1muIB6fyC1i+UiudNmZeRNDFuNhi8VNhWwd ilmXiaYwamdvNEvX0TGxB0T2AdY1f6Noc6jGViiiOuB+Hl6338Dqn7nOxRMvPDKKFC2o WCK1DUzof4O4Fzt+1ed83d7UebyjPc4Ljwl3Y=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=NAzwMoZX1c9m8KHh1dujBctLH9choBMdnPCcMI/t6sJ2Nb0ai6g5axvixLMZjtMkkJ zoDqYm2RIC42JJJB+1o1JSTzarA2t5Cbl1pOLftcYiRzxo+9ttR6hldSj7MiB8qnV8cH n/YgH9Cu/11XfHEewB//UCf0ohUviZyqi2R7M=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
It would be great if there were a way to get the subshell level nesting. ksh uses .sh.level and bash BASH_SUBSHELL.
A debugger uses this in two ways. First to indicate the level of subshell nesting on prompts, so that as you are following along you won't be surprised when a variable which had a value get unset or the value restored to its previous value. And second to maintain global state.
The general pattern here is
debug_hook:
if ((subshell_level < old_subshell_level)) ; then
eval journal file
fi
save old subshell level
work, work,
...
something that should set or change global state:
save global variable and value in journal file,
e.g. cmd='x=5'; eval $cmd; echo "$cmd" >> journal_file
It also occurs to me that if there were a variable that automatically got *unset* and stayed that way
until explicitly set, then that could be used to sumulate such a variable.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author