Commit 023f93d
committed
cmd-osbuild: don't use output capture for generate_runvm_osbuild_config
There's a massive gotcha with bash, which is that even with `set -e`,
if you're capturing output from a function, e.g. `x=$(myfunc)`, `set
-e` will not be turned on in that function. That made an error in that
function much harder to diagnose because the command _kept going_ even
though the function failed (and then the overall operation failed later
on on a much less clear error).
There's a bash option to enable this (`shopt inherit_errexit`), but I
think actually that in general we shouldn't be capturing output from
non-trivial bash functions. It's hard in bash to ensure clean stdout
output and the longer a function gets, the harder it is to keep this up
(notice e.g. how that function needs to be careful to `echo` everything
to stderr).
In this case, it's easy to rework the flow here to avoid this, so let's
do that instead.1 parent 0512d85 commit 023f93d
1 file changed
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 166 | + | |
172 | 167 | | |
173 | 168 | | |
174 | 169 | | |
| |||
223 | 218 | | |
224 | 219 | | |
225 | 220 | | |
226 | | - | |
| 221 | + | |
227 | 222 | | |
228 | 223 | | |
229 | 224 | | |
| |||
399 | 394 | | |
400 | 395 | | |
401 | 396 | | |
402 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| |||
0 commit comments