Package: bash
Version: 4.0-4
Severity: normal
I found annoing problem with bash's trap realization:
I'd like to use functions like this:
function1()
{
mkdir some/terporary/data
trap "rm -rf some/terporary/data" RETURN
....
blah-blah-blah||return 1
....
return 0
}
trap RETURN is very useful to write cleanup code in one place (but not before
every return).
But I found it's quite impossible to use this with bash:
g...@desktopvm:~$ trap
g...@desktopvm:~$ f() { trap 'echo t' RETURN; }
g...@desktopvm:~$ f
t
g...@desktopvm:~$ trap
trap -- 'echo t' RETURN
g...@desktopvm:~$ trap '' RETURN
g...@desktopvm:~$ trap
trap -- '' RETURN
g...@desktopvm:~$ f
t
g...@desktopvm:~$ trap
trap -- 'echo t' RETURN
g...@desktopvm:~$ trap 'echo -n' RETURN
g...@desktopvm:~$ f
t
g...@desktopvm:~$ trap
trap -- 'echo -n' RETURN
As you can see, if I call function which setup trap, I get the same trap for
current context.
And the only way to override this would be to setup trap in this context.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing-proposed-updates
APT policy: (680, 'testing-proposed-updates'), (680, 'testing'), (670,
'proposed-updates'), (670, 'stable'), (600, 'unstable'), (550, 'experimental')
Architecture: i386 (x86_64)
Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages bash depends on:
ii base-files 5.0.0 Debian base system miscellaneous f
ii debianutils 3.2.1 Miscellaneous utilities specific t
ii libc6 2.9-25 GNU C Library: Shared libraries
ii libncurses5 5.7+20090803-2 shared libraries for terminal hand
Versions of packages bash recommends:
ii bash-completion 1:1.0-3 programmable completion for the ba
Versions of packages bash suggests:
pn bash-doc <none> (no description available)
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]