diff options
Diffstat (limited to 'contrib/bc/tests/history.sh')
-rwxr-xr-x | contrib/bc/tests/history.sh | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/contrib/bc/tests/history.sh b/contrib/bc/tests/history.sh index 1898ae5499dc..e68d568dcec1 100755 --- a/contrib/bc/tests/history.sh +++ b/contrib/bc/tests/history.sh @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (c) 2018-2021 Gavin D. Howard and contributors. +# Copyright (c) 2018-2023 Gavin D. Howard and contributors. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -33,7 +33,16 @@ testdir=$(dirname "$script") . "$testdir/../scripts/functions.sh" -# usage: history.sh dir -a|idx [exe args...] +# Just print the usage and exit with an error. This can receive a message to +# print. +# @param 1 A message to print. +usage() { + if [ $# -eq 1 ]; then + printf '%s\n\n' "$1" + fi + printf 'usage: %s dir -a|idx [exe args...]\n' "$script" + exit 1 +} # If Python does not exist, then just skip. py=$(command -v python3) @@ -51,9 +60,14 @@ if [ "$err" -ne 0 ]; then fi fi +if [ "$#" -lt 2 ]; then + usage "Not enough arguments; expect 2 arguments" +fi + # d is "bc" or "dc" d="$1" shift +check_d_arg "$d" # idx is either an index of the test to run or "-a". If it is "-a", then all # tests are run. @@ -65,9 +79,11 @@ if [ "$#" -gt 0 ]; then # exe is the executable to run. exe="$1" shift + check_exec_arg "$exe" else exe="$testdir/../bin/$d" + check_exec_arg "$exe" fi if [ "$d" = "bc" ]; then |