shift
done
-[ "$#" = 3 ] || fatal 'Insufficient or too many arguments.'
+[ "$#" = 3 ] || die "Insufficient or too many arguments"
program_required "remap-log" \
"You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
shift
done
-[ "$#" -ge 2 ] || fatal 'Insufficient arguments'
+[ "$#" -ge 2 ] || die "Insufficient arguments"
program_required "aiaiai-locker" \
"You probably did not compile it, run 'make' in the topmost aiaiai source code directory"
shift
done
-[ "$#" -eq 1 ] || fatal 'Please, specify exactly one argument - the file with keywords'
+[ "$#" -eq 1 ] || die "Please, specify exactly one argument - the file with keywords"
file="$(readlink -ev -- "$1")"
while IFS= read -r kw; do
if [ -z "${__included_aiaiai_sh_functions-}" ]; then
__included_aiaiai_sh_functions=1
+# Print an error message and exit
+# Usage: die <message>
+die()
+{
+ fatal "Fatal error: $1"
+}
+
# Print a separator line to stdout
print_separator()
{
if ! command -v "$prg" >/dev/null 2>&1; then
message "Program \"$prg\" is required but not found in PATH"
if [ -n "$msg" ]; then
- fatal "$msg"
+ die "$msg"
else
exit 1
fi
local hdr="$1"; shift
local res="$(fetch_header "$hdr")"
- [ -n "$res" ] || fatal "Cannot find the \"$hdr:\" header"
+ [ -n "$res" ] || die "Cannot find the \"$hdr:\" header"
eval "$var=\"\$res\""
}
elif [ -d "$path" ]; then
printf "%s" "$path"
else
- fatal "not a git repository: $path"
+ die "not a git repository: $path"
fi
}
shift
done
-[ "$#" -eq 2 ] || fatal 'Please, specify exactly 2 arguments - the kernel tree and the configuration'
+[ "$#" -eq 2 ] || die "Please, specify exactly 2 arguments - the kernel tree and the configuration"
kernel_tree="$(readlink -ev -- "$1")"; shift
defconfig="$(leave_first "$1")";
if [ -n "$confdir" ]; then
defconfig="$confdir/$defconfig"
- [ -f "$defconfig" ] || fatal "$defconfig is not available"
+ [ -f "$defconfig" ] || die "$defconfig is not available"
fi
if [ -n "$bisectability" ]; then
# We share the same source tree with 'aiaiai-test-bisectability', so
# wait for it (it could be run at the previous iteration)
if [ -n "$pid_bisect" ]; then
- wait "$pid_bisect" || fatal "aiaiai-test-bisectability failed"
+ wait "$pid_bisect" || die "aiaiai-test-bisectability failed"
pid_bisect=
fi
shift
done
-[ "$#" -ge 2 ] || fatal 'Insufficient arguments'
+[ "$#" -ge 2 ] || die "Insufficient arguments"
kernel_tree="$(readlink -ev -- "$1")"; shift
defconfigs="$@"
test_configuration "$defconfig"
done
-wait "$pid_checkpatch" || fatal "checkpatch failed"
-[ -z "$keywords" ] || wait "$pid_keywords" || fatal "aiaiai-match-keywords failed"
-[ -z "$pid_bisect" ] || wait "$pid_bisect" || fatal "aiaiai-test-bisectability failed"
+wait "$pid_checkpatch" || die "checkpatch failed"
+[ -z "$keywords" ] || wait "$pid_keywords" || die "aiaiai-match-keywords failed"
+[ -z "$pid_bisect" ] || wait "$pid_bisect" || die "aiaiai-test-bisectability failed"
# Print the results
shift
done
-[ "$#" -eq 2 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 2 ] || die "Insufficient or too many arguments"
program_required "inotifywait" ""
shift
done
-[ "$#" -eq 4 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 4 ] || die "Insufficient or too many arguments"
mbox=$(readlink -fv -- "$1"); shift
fail_file="$1"; shift
dir="$(printf "%s" "$series_relatives" | sed -e "s/\(.*\)\/.*/\1/" | sort -u)"
message "Found series directory \"$dir\""
[ "$(printf "%s" "$dir" | wc -l)" -eq 0 ] ||
- fatal "Relatives live in different series directories!"
+ die "Relatives live in different series directories!"
fi
# Move the relatives from the staging to the series directory
shift
done
-[ "$#" -eq 2 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 2 ] || die "Insufficient or too many arguments"
program_required "mutt" ""
program_required "find" ""
message "The last line of previous mbox is not blank"
message "line: $line"
message "prev: $prev"
- fatal "exiting"
+ die "exiting"
fi
process_mbox
truncate -s0 -- "$mbox"
local result="$(ini_config_get "$1" "$2" "$3")"
[ -n "$result" ] ||
- fatal "Could not find config option \"$2.$3\" in \"$1\""
+ die "Could not find config option \"$2.$3\" in \"$1\""
eval "$var=\"\$result\""
}
shift
done
-[ "$#" -eq 1 ] || fatal "Insufficient or too many arguments"
+[ "$#" -eq 1 ] || die "Insufficient or too many arguments"
program_required "mutt" ""
program_required "grep" ""
# Either "To:" or "Cc:" must exist
if [ -z "$to" ] && [ -z "$cc" ]; then
- fatal "Neither \"To:\" nor \"Cc:\" header found"
+ die "Neither \"To:\" nor \"Cc:\" header found"
fi
# Find out the project name
shift
done
-[ "$#" -ge 4 ] || fatal 'Insufficient arguments'
+[ "$#" -ge 4 ] || die "Insufficient arguments"
[ -n "$tmpdir" ] || tmpdir="$(mktemp -dt "$PROG.XXXX")"