[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

controlling error handling in sourced shell code



control: tags -1 help

Hi all,

I am looking into fixing bug 807353¹ against my package dbconfig-common.
dbconfig-common is written in shell, such that it can easily be sourced
and used in maintainer scripts. The issue is that when you call a
sourced function in the test part of an if-then-fi statement, the "set
-e" option of the calling script doesn't propagate into the sourced
function. Unfortunately, dbconfig-commons error handling relies on that
behavior. I found a (slightly hacky, but probably adequate) solution for
bash², but that doesn't seem to be generic enough for e.g. dash as it
relies on the errtrace option. Does anybody here have an idea how to
solve this properly?

Paul

¹ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=807353
²
http://fvue.nl/wiki/Bash:_Error_handling#.60Break.27_trap_in_function_in_sourced_script_with_.60errtrace.27

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: