ashb commented on a change in pull request #16503:
URL: https://github.com/apache/airflow/pull/16503#discussion_r655403237
##########
File path: scripts/ci/libraries/_traps.sh
##########
@@ -31,8 +31,17 @@ function traps::add_trap() {
do
# adding trap to exiting trap
local handlers
- handlers="$( trap -p "${signal}" | cut -f2 -d \' )"
+ # shellcheck disable=SC2046
+ handlers="$(_parse_current_traps "${signal}")"
# shellcheck disable=SC2064
trap "${trap};${handlers}" "${signal}"
done
}
+
+function _parse_current_traps() {
+ local signal="$1"
+ # Yes, eval is evil, but this is the only way I was able to "parse" the
output of trap which is "already" quoted
+ eval "set -- $(trap -p "$signal")"
Review comment:
I am _none_ to happy about using eval, but this is the only way I found
to successfully parse this output bacK
```bash
$ (rap "echo 'exit 123'" EXIT; trap -p EXIT;)
+> trap 'echo '\''exit 123'\''' EXIT
+> trap -p EXIT
trap -- 'echo '\''exit 123'\''' EXIT
++> echo 'exit 123'
exit 123
```
PTAL @potiuk
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]