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]. This is the test script:
---8<---
#!/bin/bash
set -e
#set -x
trap 'echo Ho' EXIT TERM INT
echo "--traps"
trap
trap -- INT
save_traps=$(trap)
save_traps=$(echo "$save_traps" | sed -e 's/SIG//')
echo "--saved-traps"
echo "$save_traps"
eval "$save_traps"
sleep 2
exit 0
--->8---
And a question.
http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html
says:
"The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified
using a symbolic name, without the SIG prefix"
You've chosen to add the "SIG" in front of all the signal names. May I
ask why?
bash's choice is to do something more inconsistent, IMO:
trap -- 'echo Ho' EXIT
trap -- 'echo Ho' SIGINT
trap -- 'echo Ho' SIGTERM
no "SIG" in front of EXIT.
Thing is, if the quoted piece above is to be followed when doing:
eval "$save_traps"
then $(trap) should output:
trap -- 'echo Ho' EXIT
trap -- 'echo Ho' INT
trap -- 'echo Ho' TERM
Does that seem reasonable?
Cheers,
--
Cristian
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox