On 16/04/2022 10.38, Ulrich Mueller wrote:
On Sat, 16 Apr 2022, Sam James wrote:
+# @FUNCTION: edo
Just a remark: A similar command existed a long time ago under the
name "try". [1]
It was executed under "env" [2], should we also do that?
+# @USAGE: command [arg1 [arg2 ...]]
<command> should be in angle brackets, if we follow the usual
convention. Maybe even "<command> [arg]..."
+# @DESCRIPTION:
+# Executes 'command' with any given arguments and exits on failure unless
+# called under 'nonfatal'.
+edo() {
+ elog "$@"
+ "$@" || die -n "Failed to run command: $@ failed"
+}
Maybe add an ebegin/eend variant?
+1
edobe() {
nit: I'd personally would use 'edob', as shorter is sometimes better
plus every begin needs an end, so no need to explicitly state that there
is an end.
ebegin "Running $@"
"$@"
eend $? || die -n "$@ failed" > return $?
I think this return statement can be omitted since it will always be
invoked with 0 as argument, and this is the default behavior of implicit
function return (IIRC).
- Flow