SHLVL in ash
Ron Yorston
rmy at tigress.co.uk
Thu Jan 2 22:02:03 UTC 2014
Mike Frysinger wrote:
>correct. busybox knows nothing of SHLVL. it's just another env var to
>busybox. so if you set/export/whatever it, then busybox will pass it along
>unmodified.
In 1.22.0 BusyBox ash does (conditionally) know about SHLVL:
#if ENABLE_ASH_BASH_COMPAT
p = lookupvar("SHLVL");
setvar2("SHLVL", utoa(p ? atoi(p) + 1 : 1));
#endif
This is supposed to make it compatible with bash. bash does this:
[rmy at vulcan ~]$ unset SHLVL
[rmy at vulcan ~]$ sh
sh-4.2$ echo $SHLVL
1
sh-4.2$ sh
sh-4.2$ echo $SHLVL
2
sh-4.2$
Because it doesn't export SHLVL BusyBox ash behaves differently:
[rmy at f14vm busybox]$ unset SHLVL
[rmy at f14vm busybox]$ ./sh
~/busybox $ echo $SHLVL
1
~/busybox $ ./sh
~/busybox $ echo $SHLVL
1
~/busybox $
Ron
More information about the busybox
mailing list