From 7f267a5a74a5b199136e8296d9e4fd091c339a03 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Wed, 22 Apr 2020 13:23:15 +1000 Subject: [PATCH] Fix Codacy issues (#881) * Fix double quote to prevent globbing and word splitting --- .travis-ci.sh | 72 +++++++++++++++--------------- contrib/completions/complete.bash | 4 +- contrib/docker/entrypoint.sh | 8 ++-- contrib/init.d/onedrive_service.sh | 2 +- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index 28ccf6a8..cf647a8c 100644 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -13,10 +13,10 @@ CHROOT_DIR=/tmp/chroot # Debian package dependencies for the host to run ARM under QEMU DEBIAN_MIRROR="http://httpredir.debian.org/debian" -HOST_DEPENDENCIES="qemu-user-static binfmt-support debootstrap sbuild wget" +HOST_DEPENDENCIES=(qemu-user-static binfmt-support debootstrap sbuild wget) # Debian package dependencies for the chrooted environment -GUEST_DEPENDENCIES="build-essential libcurl4-openssl-dev libsqlite3-dev libgnutls-openssl27 git pkg-config libxml2" +GUEST_DEPENDENCIES=(build-essential libcurl4-openssl-dev libsqlite3-dev libgnutls-openssl27 git pkg-config libxml2) # LDC Version # Different versions due to https://github.com/ldc-developers/ldc/issues/3027 @@ -31,17 +31,17 @@ function setup_arm32_chroot { VERSION=jessie CHROOT_ARCH=armhf # Host dependencies - sudo apt-get install -qq -y ${HOST_DEPENDENCIES} + sudo apt-get install -qq -y "${HOST_DEPENDENCIES[@]}" # Download LDC compiler - wget https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARMHF}/ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz - tar -xf ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz - mv ldc2-${LDC_VERSION_ARMHF}-linux-armhf dlang-${ARCH} - rm -rf ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz + wget "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARMHF}/ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz" + tar -xf "ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz" + mv "ldc2-${LDC_VERSION_ARMHF}-linux-armhf" "dlang-${ARCH}" + rm -rf "ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz" # Create chrooted environment - sudo mkdir ${CHROOT_DIR} - sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch=${CHROOT_ARCH} ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR} - sudo cp /usr/bin/qemu-arm-static ${CHROOT_DIR}/usr/bin/ - sudo chroot ${CHROOT_DIR} /debootstrap/debootstrap --second-stage + sudo mkdir "${CHROOT_DIR}" + sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch="${CHROOT_ARCH}" "${VERSION}" "${CHROOT_DIR}" "${DEBIAN_MIRROR}" + sudo cp /usr/bin/qemu-arm-static "${CHROOT_DIR}"/usr/bin/ + sudo chroot "${CHROOT_DIR}" /debootstrap/debootstrap --second-stage sudo sbuild-createchroot --arch=${CHROOT_ARCH} --foreign --setup-only ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR} configure_chroot } @@ -53,12 +53,12 @@ function setup_arm64_chroot { VERSION64=stretch CHROOT_ARCH64=arm64 # Host dependencies - sudo apt-get install -qq -y ${HOST_DEPENDENCIES} + sudo apt-get install -qq -y "${HOST_DEPENDENCIES[@]}" # Download LDC compiler - wget https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARM64}/ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz - tar -xf ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz - mv ldc2-${LDC_VERSION_ARM64}-linux-aarch64 dlang-${ARCH} - rm -rf ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz + wget "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARM64}/ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz" + tar -xf "ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz" + mv "ldc2-${LDC_VERSION_ARM64}-linux-aarch64" "dlang-${ARCH}" + rm -rf "ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz" # ARM64 qemu-debootstrap needs to be 1.0.78, Trusty is 1.0.59 #sudo echo "deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" >> /etc/apt/sources.list @@ -67,7 +67,7 @@ function setup_arm64_chroot { sudo apt-get install -t xenial debootstrap # Create chrooted environment - sudo mkdir ${CHROOT_DIR} + sudo mkdir "${CHROOT_DIR}" sudo qemu-debootstrap --arch=${CHROOT_ARCH64} ${VERSION64} ${CHROOT_DIR} ${DEBIAN_MIRROR} configure_chroot } @@ -79,19 +79,19 @@ function setup_x32_chroot { VERSION=jessie CHROOT_ARCH32=i386 # Host dependencies - sudo apt-get install -qq -y ${HOST_DEPENDENCIES} + sudo apt-get install -qq -y "${HOST_DEPENDENCIES[@]}" # Download DMD compiler DMDVER=2.083.1 - wget http://downloads.dlang.org/releases/2.x/${DMDVER}/dmd.${DMDVER}.linux.tar.xz - tar -xf dmd.${DMDVER}.linux.tar.xz - mv dmd2 dlang-${ARCH} - rm -rf dmd.${DMDVER}.linux.tar.xz + wget "http://downloads.dlang.org/releases/2.x/${DMDVER}/dmd.${DMDVER}.linux.tar.xz" + tar -xf "dmd.${DMDVER}.linux.tar.xz" + mv dmd2 "dlang-${ARCH}" + rm -rf "dmd.${DMDVER}.linux.tar.xz" # Create chrooted environment - sudo mkdir ${CHROOT_DIR} + sudo mkdir "${CHROOT_DIR}" sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch=${CHROOT_ARCH32} ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR} - sudo cp /usr/bin/qemu-i386-static ${CHROOT_DIR}/usr/bin/ - sudo cp /usr/bin/qemu-x86_64-static ${CHROOT_DIR}/usr/bin/ - sudo chroot ${CHROOT_DIR} /debootstrap/debootstrap --second-stage + sudo cp /usr/bin/qemu-i386-static "${CHROOT_DIR}/usr/bin/" + sudo cp /usr/bin/qemu-x86_64-static "${CHROOT_DIR}/usr/bin/" + sudo chroot "${CHROOT_DIR}" /debootstrap/debootstrap --second-stage sudo sbuild-createchroot --arch=${CHROOT_ARCH32} --foreign --setup-only ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR} configure_chroot } @@ -103,19 +103,19 @@ function configure_chroot { chmod a+x envvars.sh # Install dependencies inside chroot - sudo chroot ${CHROOT_DIR} apt-get update - sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install -qq -y ${GUEST_DEPENDENCIES} + sudo chroot "${CHROOT_DIR}" apt-get update + sudo chroot "${CHROOT_DIR}" apt-get --allow-unauthenticated install -qq -y "${GUEST_DEPENDENCIES[@]}" # Create build dir and copy travis build files to our chroot environment - sudo mkdir -p ${CHROOT_DIR}/${TRAVIS_BUILD_DIR} - sudo rsync -a ${TRAVIS_BUILD_DIR}/ ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/ + sudo mkdir -p "${CHROOT_DIR}"/"${TRAVIS_BUILD_DIR}" + sudo rsync -a "${TRAVIS_BUILD_DIR}"/ "${CHROOT_DIR}"/"${TRAVIS_BUILD_DIR}"/ # Indicate chroot environment has been set up - sudo touch ${CHROOT_DIR}/.chroot_is_done + sudo touch "${CHROOT_DIR}"/.chroot_is_done # Call ourselves again which will cause tests to run - sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && chmod a+x ./.travis-ci.sh" - sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && ./.travis-ci.sh" + sudo chroot "${CHROOT_DIR}" bash -c "cd ${TRAVIS_BUILD_DIR} && chmod a+x ./.travis-ci.sh" + sudo chroot "${CHROOT_DIR}" bash -c "cd ${TRAVIS_BUILD_DIR} && ./.travis-ci.sh" } function build_onedrive { @@ -129,12 +129,12 @@ function build_onedrive { else if [ "${ARCH}" = "x32" ]; then # 32Bit DMD Build - ./configure DC=${HOMEDIR}/dlang-${ARCH}/linux/bin32/dmd + ./configure DC="${HOMEDIR}"/dlang-"${ARCH}"/linux/bin32/dmd make clean; make else # LDC Build - ARM32, ARM64 - ./configure DC=${HOMEDIR}/dlang-${ARCH}/bin/ldmd2 + ./configure DC="${HOMEDIR}"/dlang-"${ARCH}"/bin/ldmd2 make clean; make fi @@ -154,7 +154,7 @@ function test_onedrive { ./makefiles.sh cd .. mkdir -p ~/.config/onedrive/ - echo $ODP > ~/.config/onedrive/refresh_token + echo "$ODP" > ~/.config/onedrive/refresh_token ./onedrive --synchronize --verbose --syncdir '~/OneDriveALT' # OneDrive Cleanup rm -rf ~/OneDriveALT/* diff --git a/contrib/completions/complete.bash b/contrib/completions/complete.bash index aa09f3e5..2ebe089a 100644 --- a/contrib/completions/complete.bash +++ b/contrib/completions/complete.bash @@ -12,7 +12,7 @@ _onedrive() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} - options='--check-for-nomount --check-for-nosync --debug-https --disable-notifications --display-config --display-sync-status --download-only --disable-upload-validation --dry-run --enable-logging --force-http-1.1 --force-http-2 --local-first --logout -m --monitor --no-remote-delete --print-token --resync --skip-dot-files --skip-symlinks --synchronize --upload-only -v --verbose --version -h --help' + options='--check-for-nomount --check-for-nosync --debug-https --disable-notifications --display-config --display-sync-status --download-only --disable-upload-validation --dry-run --enable-logging --force-http-1.1 --force-http-2 --local-first --logout -m --monitor --no-remote-delete --print-token --resync --skip-dot-files --skip-symlinks --synchronize --upload-only -v --verbose --version -h --help' argopts='--create-directory --get-O365-drive-id --remove-directory --single-directory --source-directory' # Loop on the arguments to manage conflicting options @@ -31,7 +31,7 @@ _onedrive() return 0 ;; *) - COMPREPLY=( $( compgen -W "$options $argopts" -- $cur)) + COMPREPLY=( $( compgen -W "$options $argopts" -- "$cur")) return 0 ;; esac diff --git a/contrib/docker/entrypoint.sh b/contrib/docker/entrypoint.sh index 967a75e2..72eb8d94 100755 --- a/contrib/docker/entrypoint.sh +++ b/contrib/docker/entrypoint.sh @@ -6,17 +6,17 @@ set +H -xeuo pipefail : ${ONEDRIVE_GID:=$(stat /onedrive/data -c '%g')} # Create new group using target GID -if ! odgroup="$(getent group $ONEDRIVE_GID)"; then +if ! odgroup="$(getent group "$ONEDRIVE_GID")"; then odgroup='onedrive' - groupadd "${odgroup}" -g $ONEDRIVE_GID + groupadd "${odgroup}" -g "$ONEDRIVE_GID" else odgroup=${odgroup%%:*} fi # Create new user using target UID -if ! oduser="$(getent passwd $ONEDRIVE_UID)"; then +if ! oduser="$(getent passwd "$ONEDRIVE_UID")"; then oduser='onedrive' - useradd -m "${oduser}" -u $ONEDRIVE_UID -g $ONEDRIVE_GID + useradd -m "${oduser}" -u "$ONEDRIVE_UID" -g "$ONEDRIVE_GID" else oduser="${oduser%%:*}" usermod -g "${odgroup}" "${oduser}" diff --git a/contrib/init.d/onedrive_service.sh b/contrib/init.d/onedrive_service.sh index e28e0e79..4d03ff03 100644 --- a/contrib/init.d/onedrive_service.sh +++ b/contrib/init.d/onedrive_service.sh @@ -1,5 +1,5 @@ #!/bin/bash # This script is to assist in starting the onedrive client when using init.d APP_OPTIONS="--monitor --verbose --enable-logging" -onedrive $APP_OPTIONS > /dev/null 2>&1 & +onedrive "$APP_OPTIONS" > /dev/null 2>&1 & exit 0