summaryrefslogtreecommitdiff
path: root/config/coreboot/e6400_4mb/target.cfg
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-03-27 01:19:39 +0000
committerLeah Rowe <leah@libreboot.org>2024-03-27 01:50:31 +0000
commit6ebab10caa5be6fc1cfd244e745851687d4bd70d (patch)
tree0b983459c0cbc1b8998186975f9a571decb05592 /config/coreboot/e6400_4mb/target.cfg
parent6b11f1b055466982747f65665506173a0b22557b (diff)
safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in the $PATH will override that program. for example, you could make a function called ls() and this would override the standand "ls". in lbmk, a part of it was first trying to run the "fail" command, deferring to "err", because some scripts call fail() which does some minor cleanup before calling err. in most cases, fail() is not defined, and it's possible that the user could have a program called "fail" in their $PATH, the behaviour of which we could not determine, and it could have disastrous effects. lbmk error handling has been re-engineered in such a way that the err function is defined in a variable, which defaults to err_ which calls err_, so defined under include/err.sh. in functions that require cleanup prior to error handling, a fail() function is still defined, and err is overridden, thus: err="fail" this change has made xx_() obsolete, so now only x_ is used. the x_ function is a wrapper that can be used to run a command and exit with non-zero status (from lbmk) if the command fails. the xx_ command did the same thing, but called fail() which would have called err(); now everything is $err example: rm -f "$filename" || err "could not delete file" this would now be: rm -f "$filename" || $err "could not delete file" overriding of err= must be done *after* including err.sh. for example: err="fail" . "include/err.sh" ^ this is wrong. instead, one must do: . "include/err.sh" err="fail" this is because err is set as a global variable under err.sh the new error handling is much cleaner, and safer. it also reduces the chance of mistakes such as: calling err when you meant to call fail. this is because the standard way is now to call $err, so you set err="fail" at the top of the script and all is well. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'config/coreboot/e6400_4mb/target.cfg')
0 files changed, 0 insertions, 0 deletions