Updates to expect_match
change order of positional params to match that of grep
fix bug that prevented output of usage when run without opts
reformat usage statement to be more readable
Change-Id: Ib51d35367543e217d78d0748787b8220026bace4
diff --git a/setup.sh b/setup.sh
index 08c3fd1..5a5d39b 100644
--- a/setup.sh
+++ b/setup.sh
@@ -329,20 +329,20 @@
## Watch a file for a pattern and exit when matched or timed out
function expect_match
{
- local log_path="$(realpath $1)"
- local match_string="$2"
+ local match_string="$1"
+ local log_path="$2"
local timeout="$3"
- local usage="Usage: expect_match <file path> <pattern> [timeout]
- filepath: Path to file to search
- pattern: grep regexp pattern
- timeout: optional timeout, defaults to 30s"
-
- if [[ -z "${log_path}" ]]; then
- echo usage
+ if [[ -z "${match_string}" ]] || [[ -z "${log_path}" ]]; then
+ echo "Usage: expect_match <pattern> <file path> [timeout]"
+ echo " pattern: grep regexp pattern"
+ echo " file path: Path to file to search"
+ echo " timeout: optional timeout, defaults to 30s"
return 1
fi
+ log_path="$(realpath ${log_path})"
+
if [[ -z "${timeout}" ]]; then
timeout="30s"
fi