[Bug 791855] New: bash drops errexit option in sourced file
https://bugzilla.novell.com/show_bug.cgi?id=791855 https://bugzilla.novell.com/show_bug.cgi?id=791855#c0 Summary: bash drops errexit option in sourced file Classification: openSUSE Product: openSUSE 12.2 Version: Final Platform: x86-64 OS/Version: openSUSE 12.2 Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: rschiele@gmail.com QAContact: qa-bugs@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11 While normally sourced files have identical options set like the invoking environment this is not true if the sourcing is done from within a function foo that was called with something like: foo && true The following example demonstrates this: $ cat bug #!/bin/bash set -e int() { echo A: $- . source echo D: $- } echo Broken: int && true echo OK: int $ cat source echo B: $- false echo C: $- $ bash bug Broken: A: ehB B: hB C: hB D: ehB OK: A: ehB B: ehB $ This error showed up in bash 4.0 first and was not present in 3.2 or older. As you can see in the invocation "int && true" the flag is still set inside the function but magically disappears once the file is sourced, while in the second incocation "int" everything behaves as expected. Apparently something gets broken when the exit on error is temporarily disabled for the chained command "int && true" because while it gets properly restored within the function itself it disappears again when sourcing the other file. This problem was also reported upstream as https://savannah.gnu.org/support/index.php?108191 Reproducible: Always Steps to Reproduce: Invoke the scripts as described in the details section. Actual Results: errexit option gets dropped in sourced file. Expected Results: errexit option should not get dropped in sourced file. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=791855
https://bugzilla.novell.com/show_bug.cgi?id=791855#c1
Jiaying ren
https://bugzilla.novell.com/show_bug.cgi?id=791855
https://bugzilla.novell.com/show_bug.cgi?id=791855#c2
Robert Schiele
https://bugzilla.novell.com/show_bug.cgi?id=791855
https://bugzilla.novell.com/show_bug.cgi?id=791855#c
Jiaying ren
https://bugzilla.novell.com/show_bug.cgi?id=791855
https://bugzilla.novell.com/show_bug.cgi?id=791855#c3
Dr. Werner Fink
https://bugzilla.novell.com/show_bug.cgi?id=791855
https://bugzilla.novell.com/show_bug.cgi?id=791855#c4
Robert Schiele
https://bugzilla.novell.com/show_bug.cgi?id=791855
https://bugzilla.novell.com/show_bug.cgi?id=791855#c5
Robert Schiele
participants (1)
-
bugzilla_noreply@novell.com