Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: SHLVL not updated in environment



% 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@xxxxxxx>                  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
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author