Package: bash
Version: 3.1dfsg-9
Severity: normal
This isn't documented in the bash manpage section for -e, so I assume
it's a bug (either in the manpage or with "set -e" itself)
If "set -e" is active, and you have a function which calls (in a "simple"
way, as defined by the set -e manpage section), then:
1) If you call the function normally, then the function will exit
immediately when that line runs, and not run any later lines.
This is as expected.
However:
2) If you call that function as part of a non-simple statement
(eg: if test_func; ) then the function won't return after that
line. It will continue executing the function after that line.
This seems to be a dangerous side-effect.
Here is an example script which demonstrates this:
### SCRIPT STARTS ###
#!/bin/bash
set -e
test_func() {
false
echo "ERROR: This should never run when 'set -e' is active!"
}
# Try the function with an if:
if test_func; then
echo "ERROR: test_func succeeded where it was expected to fail!"
else
echo "test_func failed as expected"
fi
# Now try the function again, outside an if:
test_func # Doesn't print the error message this time
# Logic never gets here, as expected:
echo "This never runs"
### SCRIPT ENDS ###
I assume that for reverse compatibility you won't 'fix' how set -e
works. But please do update the bash manpage section for 'set -e'
to document this unexpected function behaviour.
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (990, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages bash depends on:
ii base-files 4.0.2 Debian base system miscellaneous f
ii debianutils 2.28.4 Miscellaneous utilities specific t
ii libc6 2.7-6 GNU C Library: Shared libraries
ii libncurses5 5.6+20080203-1 Shared libraries for terminal hand
Versions of packages bash recommends:
pn bash-completion <none> (no description available)
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]