On Wednesday 23 September 2009 23:52, Cristian Ionescu-Idbohrn wrote:
> On Wed, 23 Sep 2009, Cristian Ionescu-Idbohrn wrote:
>
> > On Wed, 23 Sep 2009, Denys Vlasenko wrote:
> >
> > > On Wednesday 23 September 2009 00:26, Denys Vlasenko wrote:
> > > > Sigh.
> > > >
> > > > I'm leaning towards special-casing `xxx` or $(xxx) which contains
> > > > exactly one word, "trap".
> > >
> > > Here is it.
> >
> > Awsome.
>
> That should be "Awesome" :)
>
> Tested that now. The:
>
> eval "$save_traps"
>
> produces an error:
>
> .../tests/trap-test.sh: eval: line 3: Ho: not found
>
> when using ash. No errors when using bash [GNU bash, version
> 4.0.33(1)-release].
I see. It's an EXIT trap firing when `trap` terminates...
It's not easy to fix due to some peculiarities of ash.c code.
Simplest but dirty solution would be to to unset EXIT trap
in `trap`, but it will not show EXIT in `trap` output too.
Which is bad, but "less bad" that what we have now.
--
vda
diff -d -urpN busybox.3/shell/ash.c busybox.4/shell/ash.c
--- busybox.3/shell/ash.c 2009-09-24 02:44:22.000000000 +0200
+++ busybox.4/shell/ash.c 2009-09-24 03:04:31.000000000 +0200
@@ -4525,7 +4525,7 @@ clear_traps(void)
INT_OFF;
free(*tp);
*tp = NULL;
- if (tp != &trap[0])
+ if ((tp - trap) != 0)
setsignal(tp - trap);
INT_ON;
}
@@ -4596,6 +4596,8 @@ forkchild(struct job *jp, union node *n,
*
* Our solution: ONLY bare $(trap) or `trap` is special.
*/
+ free(trap[0]); /* Prevent EXIT trap from firing in `trap` */
+ trap[0] = NULL;
} else {
clear_traps();
}
@@ -13023,6 +13025,7 @@ exitshell(void)
if (p) {
trap[0] = NULL;
evalstring(p, 0);
+ free(p);
}
flush_stdout_stderr();
out:
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox