From ad3273986024c80cfe067d1b77983901a41b6d01 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 16 Feb 2020 20:07:37 +0100 Subject: shellcheck: fix usse -n instead of ! -z (SC2236 SC2237) - https://www.shellcheck.net/wiki/SC2236 -- Use -n instead of ! -z. - https://www.shellcheck.net/wiki/SC2237 -- Use [ -n .. ] instead of ! [ -z .... Signed-off-by: Markus Heiser --- utils/lxc.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'utils/lxc.sh') diff --git a/utils/lxc.sh b/utils/lxc.sh index d0ad49bd1..0c198babc 100755 --- a/utils/lxc.sh +++ b/utils/lxc.sh @@ -31,6 +31,7 @@ ubu1804_boilerplate=" export DEBIAN_FRONTEND=noninteractive apt-get install -y git curl wget " +# shellcheck disable=SC2034 ubu1904_boilerplate="$ubu1804_boilerplate" REMOTE_IMAGES=() @@ -75,7 +76,7 @@ all LXC containers: ${LOCAL_IMAGES[@]} EOF - [ ! -z "${1+x}" ] && err_msg "$1" + [ -n "${1+x}" ] && err_msg "$1" } lxd_info() { @@ -255,7 +256,7 @@ lxc_boilerplate_containers() { lxc start -q "${HOST_PREFIX}-${shortname}" &>/dev/null boilerplate_script="${shortname}_boilerplate" boilerplate_script="${!boilerplate_script}" - if [[ ! -z "${boilerplate_script}" ]]; then + if [[ -n "${boilerplate_script}" ]]; then echo "$boilerplate_script" \ | lxc exec "${HOST_PREFIX}-${shortname}" -- bash \ | prefix_stdout " ${HOST_PREFIX}-${shortname} | " @@ -305,11 +306,13 @@ add_subordinate_ids() { del_subordinate_ids() { local out + local exit_value if grep "root:${HOST_USER_ID}:1" /etc/subuid -qs; then # TODO: root user is always in use by process 1, how can we remove subordinates? info_msg "remove lxd permission to map ${HOST_USER_ID}'s user/group id through" out=$(usermod --del-subuids "${HOST_USER_ID}-${HOST_USER_ID}" --del-subgids "${HOST_GROUP_ID}-${HOST_GROUP_ID}" root 2>&1) - if [ ! -z $? ]; then + exit_val=$? + if [ $exit_val -ne 0 ]; then err_msg "$out" fi else -- cgit v1.2.3