From c90ad4cf2bc72efac776a61ffa6ab5bfce806dad Mon Sep 17 00:00:00 2001 From: Phan Le Date: Wed, 15 Jul 2020 19:02:55 -0700 Subject: [PATCH] scripts: fix the scripts load-images.sh and save-images.sh in the case user provides invalid flags When user provides an invalid flag, print out error message and help menu instead of looping forever Longhorn #1419 Signed-off-by: Phan Le --- scripts/load-images.sh | 7 ++++++- scripts/save-images.sh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/load-images.sh b/scripts/load-images.sh index 3ce1d0f..f9eaef1 100755 --- a/scripts/load-images.sh +++ b/scripts/load-images.sh @@ -24,6 +24,11 @@ while [[ $# -gt 0 ]]; do help="true" shift ;; + *) + echo "Error! invalid flag: ${key}" + help="true" + break + ;; esac done @@ -65,4 +70,4 @@ for i in $(cat ${list}); do docker push ${reg}longhornio/${i} ;; esac -done +done \ No newline at end of file diff --git a/scripts/save-images.sh b/scripts/save-images.sh index 71ffe87..69a28c5 100755 --- a/scripts/save-images.sh +++ b/scripts/save-images.sh @@ -19,6 +19,11 @@ while [[ $# -gt 0 ]]; do help="true" shift ;; + *) + echo "Error! invalid flag: ${key}" + help="true" + break + ;; esac done @@ -42,4 +47,4 @@ done if [[ $images ]]; then docker save $(cat ${list} | tr '\n' ' ') | gzip -c > ${images} -fi +fi \ No newline at end of file