From c2dcd58ec46b39987ae89cb43c2e0d8050245d25 Mon Sep 17 00:00:00 2001 From: Doi Yusuke Date: Fri, 4 Nov 2016 02:45:44 +0900 Subject: [PATCH] Add argument task to setup.sh --- script/setup.sh | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/script/setup.sh b/script/setup.sh index 17db39f..916fe9a 100755 --- a/script/setup.sh +++ b/script/setup.sh @@ -5,20 +5,29 @@ invalidPID(){ [ $1 -lt 9 ] && return 1 return 0 } - -echo "Please select your device" -echo "1. ICS USB ADAPTER" -echo "2. SERIAL USB ADAPTER" -echo "3~5: nothing" -echo "6. ICS USB ADAPTER HS" -echo "7. SERIAL USB ADAPTER HS" -echo "8. DUAl USB ADAPTER HS" -read onePID -expr $onePID + 1 > /dev/null 2>&1 -INTCHECK=$? -if [ $INTCHECK -gt 1 ]; then - echo "Invalid argument" - return 1 +if [ $# -gt 0 ]; then + expr $1 + 1 > /dev/null 2>&1 + inputCheck=$? +else + inputCheck=5 +fi +if [ $inputCheck -gt 1 ]; then + echo "Please select your device" + echo "1. ICS USB ADAPTER" + echo "2. SERIAL USB ADAPTER" + echo "3~5: nothing" + echo "6. ICS USB ADAPTER HS" + echo "7. SERIAL USB ADAPTER HS" + echo "8. DUAl USB ADAPTER HS" + read onePID + expr $onePID + 1 > /dev/null 2>&1 + INTCHECK=$? + if [ $INTCHECK -gt 1 ]; then + echo "Invalid argument" + return 1 +fi +else + onePID=$1 fi if invalidPID $onePID; then echo "Out of range"