SHLVL in ash
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Mon Jan 6 09:28:21 UTC 2014
On 2 January 2014 23:03:02 Ron Yorston <rmy at tigress.co.uk> wrote:
> 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 $
Did I forget to export it when it was not exported yet?
Patches welcome..
Thanks,
Sent with AquaMail for Android
http://www.aqua-mail.com
More information about the busybox
mailing list