On Mon, 21 Sep 2009, Denys Vlasenko wrote:

> On Monday 21 September 2009 12:59, Cristian Ionescu-Idbohrn wrote:
> > http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html
> >
> > ,----
> > | The shell shall format the output, including the proper use of
> > | quoting, so that it is suitable for reinput to the shell as commands
> > | that achieve the same trapping results. For example:
> > |
> > | save_traps=$(trap)
> > | ...
> > | eval "$save_traps"
> > `----
> >
> > ash resets all traps when running trap in a subshell, so the
> > save_traps variable will be empty.  bash does the right thing.
>
> Holy sh*t. What is the "right thing in this case, eh?

Sorry for not being clear.  This is what I mean:

---8<---
#!/bin/bash

set -e
#set -x

trap 'echo Ho' EXIT TERM INT

echo "--traps"
trap
trap -- INT

save_traps=$(trap)
echo "--saved-traps"
echo "$save_traps"

sleep 2

exit 0
--->8---

I want to be able to store the list of traps in a variable.


Cheers,

-- 
Cristian
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to