zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: SHLVL not updated in environment
@ 2004-09-20 13:09 Peter Stephenson
  2004-09-20 14:19 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2004-09-20 13:09 UTC (permalink / raw)
  To: Zsh hackers list

% zsh
% print $SHLVL
3
% printenv SHLVL
2

This is a bug, right?  I'm not missing some extreme sublety?
Is this the right fix, rather than reversing the sense of the test?
It seems that SHLVL has to be exported for it to work, although the
documentation doesn't explicitly indicate it always will be exported.

((SHLVL++, SHLVL--)) is a workaround.

Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.89
diff -u -r1.89 params.c
--- Src/params.c	17 Sep 2004 09:25:42 -0000	1.89
+++ Src/params.c	20 Sep 2004 13:05:20 -0000
@@ -594,8 +594,8 @@
 	addenv(pm, pm->u.str);
     pm = (Param) paramtab->getnode(paramtab, "SHLVL");
     sprintf(buf, "%d", (int)++shlvl);
-    if (!(pm->flags & PM_EXPORTED))
-	addenv(pm, buf);
+    /* shlvl value in environment needs updating unconditionally */
+    addenv(pm, buf);
 
     /* Add the standard non-special parameters */
     set_pwd_env();

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

end of thread, other threads:[~2004-09-20 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-20 13:09 PATCH: SHLVL not updated in environment Peter Stephenson
2004-09-20 14:19 ` Bart Schaefer
2004-09-20 14:30   ` 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).