ash: Set SHLVL in ASH_BASH_COMPAT
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Fri, 8 Nov 2013 13:25:24 +0000 (14:25 +0100)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Fri, 8 Nov 2013 13:30:20 +0000 (14:30 +0100)
function                                             old     new   delta
ash_main                                            1456    1505     +49
.rodata                                           148488  148494      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
shell/ash.c

index f9b4d3fe659702cb4617fe613929f339ea4c1d79..71ef9a690f5941f567e35b7c911b7a248fde45d4 100644 (file)
@@ -13012,7 +13012,10 @@ init(void)
                }
 
                setvar2("PPID", utoa(getppid()));
-
+#if ENABLE_ASH_BASH_COMPAT
+               p = lookupvar("SHLVL");
+               setvar2("SHLVL", utoa(p ? atoi(p) + 1 : 1));
+#endif
                p = lookupvar("PWD");
                if (p) {
                        if (*p != '/' || stat(p, &st1) || stat(".", &st2)