Fix shellcheck issues in debian-setup.sh.
authorGerald Combs <gerald@wireshark.org>
Mon, 25 Jun 2018 22:39:30 +0000 (15:39 -0700)
committerAnders Broman <a.broman58@gmail.com>
Tue, 26 Jun 2018 11:53:14 +0000 (11:53 +0000)
Change-Id: I54956ea4de5e07f1d2a705f9b77624d6c25511a6
Reviewed-on: https://code.wireshark.org/review/28438
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
CMakeLists.txt
tools/debian-setup.sh

index 7ec41d82e56e75f9478b511db9ac88cba822a097..4a1311625958e072ba73ef7a1d85b8f35ad24f47 100644 (file)
@@ -3067,6 +3067,7 @@ if(SHELLCHECK_EXECUTABLE)
                        packaging/macosx/osx-app.sh.in
                        packaging/macosx/osx-dmg.sh.in
                        tools/compress-pngs.sh
+                       tools/debian-setup.sh
                        tools/git-export-release.sh
                        tools/fuzz-test.sh
                        tools/gen-bugnote
index 001be5a1fe35fcd822a224bd9d379981f4d9e899..2321afe7032eb0bcbe363c3289e3577d73368568 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Setup development environment on Debian and derivatives such as Ubuntu
 #
 # Wireshark - Network traffic analyzer
 
 if [ "$1" = "--help" ]
 then
-       echo "\nUtility to setup a debian-based system for Wireshark Development.\n"
-       echo "The basic usage installs the needed software\n\n"
-       echo "Usage: $0 [--install-optional] [...other options...]\n"
-       echo "\t--install-optional: install optional software as well"
-       echo "\t[other]: other options are passed as-is to apt\n"
+       printf "\\nUtility to setup a debian-based system for Wireshark Development.\\n"
+       printf "The basic usage installs the needed software\\n\\n"
+       printf "Usage: %s [--install-optional] [...other options...]\\n" "$0"
+       printf "\\t--install-optional: install optional software as well"
+       printf "\\t[other]: other options are passed as-is to apt\\n"
        exit 1
 fi
 
 # Check if the user is root
-if [ $(id -u) -ne 0 ]
+if [ "$(id -u)" -ne 0 ]
 then
        echo "You must be root."
        exit 1
@@ -83,6 +83,7 @@ add_package() {
                return 1
        elif [ -n "$versionreq" ]; then
                # Require minimum version or fail.
+               # shellcheck disable=SC2086
                dpkg --compare-versions $version $versionreq || return 1
        fi
 
@@ -123,13 +124,10 @@ then
        ACTUAL_LIST="$ACTUAL_LIST $ADDITIONAL_LIST"
 fi
 
-apt-get install $ACTUAL_LIST $OPTIONS
-if [ $? != 0 ]
-then
-       exit 2
-fi
+# shellcheck disable=SC2086
+apt-get install $ACTUAL_LIST $OPTIONS || exit 2
 
 if [ ! $ADDITIONAL ]
 then
-       echo "\n*** Optional packages not installed. Rerun with --install-optional to have them.\n"
+       printf "\\n*** Optional packages not installed. Rerun with --install-optional to have them.\\n"
 fi