zsh-workers
 help / color / mirror / code / Atom feed
* Request: a way to get the subshell level nesting
@ 2008-09-05 14:11 Rocky Bernstein
  2008-09-05 19:49 ` Phil Pennock
  2008-09-05 20:45 ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Rocky Bernstein @ 2008-09-05 14:11 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 962 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 1515 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-09-06 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-05 14:11 Request: a way to get the subshell level nesting Rocky Bernstein
2008-09-05 19:49 ` Phil Pennock
2008-09-05 19:55   ` Rocky Bernstein
2008-09-05 20:45 ` Peter Stephenson
2008-09-05 21:36   ` Rocky Bernstein
2008-09-06 21:23     ` Peter Stephenson

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).