OSDN Git Service

User "return" instead of "exit" in shell scripts
authorJack He <siyuanh@google.com>
Tue, 3 Mar 2020 01:31:44 +0000 (17:31 -0800)
committerJack He <siyuanh@google.com>
Tue, 3 Mar 2020 01:32:54 +0000 (17:32 -0800)
* Exit will cause the parent terminal to exit

Test: source cert/set_up_and_run_device_cert.sh --help
Change-Id: I07005a5a3d12f1c01429f7fb70946f2c39a942b9

gd/cert/set_up_acts.sh
gd/cert/set_up_and_run_device_cert.sh

index a902efc..60bfdd2 100755 (executable)
@@ -59,7 +59,7 @@ function CompileBluetoothPacketsPython3 {
 
 if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
     UsageSourcedNotExecuted
-    exit 1
+    return 1
 fi
 
 if [[ -z "$ANDROID_BUILD_TOP" ]] ; then
index 297918d..dcdcd2e 100755 (executable)
@@ -12,7 +12,7 @@ function menu-adb() {
     result=0
     if [ $LEN -lt 1 ]; then
         echo "No devices connected!"
-        exit 1
+        return 1
     fi
 
     if [ "$LEN" == "" ]; then
@@ -47,7 +47,7 @@ function menu-adb() {
         echo
         echo "Please choose a correct index!" 1>&2
         echo
-        exit 1
+        return 1
     fi
 
     SERIAL=${SERIALS[$answer]}
@@ -72,7 +72,7 @@ function get-android-root() {
         echo
         echo "Needs to be ran in the android tree"
         echo
-        exit 1
+        return 1
     fi
     echo "${android_root}"
 }
@@ -100,7 +100,7 @@ if [ $# -gt 0 ]; then
             echo " -h | Help(this) Menu"
             echo " -d | Dry run; just prints commands"
             echo
-            exit 0
+            return 0
         elif [ "$var" == "-d" ]; then
             DRY_RUN="echo"
         elif [ "$var" == "-b" ]; then
@@ -122,7 +122,7 @@ if [ "${CERT_SERIAL}" == "${DUT_SERIAL}" ]; then
     echo
     echo "ERROR: CERT and DUT cannot be the same device, or you only have one device connected!"
     echo
-    exit 1
+    return 1
 fi
 
 ## Start builds