diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2020-02-16 20:07:37 +0100 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarit.de> | 2020-02-16 20:07:37 +0100 |
| commit | ad3273986024c80cfe067d1b77983901a41b6d01 (patch) | |
| tree | e561ad42141b36109f96ac17f671563de0355f80 /utils/lxc.sh | |
| parent | e8cf22504650f742da247bc923abebccec869676 (diff) | |
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 <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/lxc.sh')
| -rwxr-xr-x | utils/lxc.sh | 9 |
1 files changed, 6 insertions, 3 deletions
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 |