[__lxc_container] fix some shellchecks (incl. warnings)

To the error in the `explorer/state`: It's intended, as it passes
possible parameters to the command. Varibale will set unquoted, so
word splitting take action, but the quotes inside the variable work.
This commit is contained in:
matze 2020-07-05 20:50:40 +02:00
commit 1b69d037ac
3 changed files with 6 additions and 4 deletions

View file

@ -19,12 +19,14 @@ lxcpath="$(cat "$__object/parameter/lxcpath" 2>/dev/null || true)"
# assemble optional parameters
LXC_PARAM=""
if [ "$lxcpath" ]; then
# shellcheck disable=SC2089
LXC_PARAM="$LXC_PARAM -P \"$lxcpath\""
fi
# function to get information
lxc_info() {
# shellcheck disable=SC2090 disable=SC2086
if [ "$user" != "$USER" ]; then
su -s "$(which -- lxc-info)" -- "$user" $LXC_PARAM -n "$name" -H "$@"
else

View file

@ -44,7 +44,7 @@ fi
# shortcut for checking config changes
tmppath="$__object/files/remote-tmpfile"
config_changes() {
if ( [ -f "${tmppath}_add" ] || [ -f "${tmppath}_del" ] ); then
if [ -f "${tmppath}_add" ] || [ -f "${tmppath}_del" ]; then
return 0
else
return 1
@ -91,7 +91,7 @@ USER
backingstore_opts=""
if [ -f "$__object/parameter/backingstore" ]; then
# -B works for both types, they have different long opts
backingstore_opts="-B '$(cat "$__object/parameter/backingstore")'"
backingstore_opts="$backingstore_opts -B '$(cat "$__object/parameter/backingstore")'"
# add parameters if available
bdev_add_if_available dir
@ -149,7 +149,7 @@ LXC
# at last, apply custom options
if [ -f "$__object/parameter/template-opts" ]; then
while read line; do
while read -r line; do
template_opts="$template_opts $line"
done < "$__object/parameter/template-opts"
fi

View file

@ -93,7 +93,7 @@ fi
write_multi_param() {
if ! [ -f "$__object/parameter/$1" ]; then return 0; fi
while read line; do
while read -r line; do
if [ "$line" = "-" ]; then
# append stdin
cat "$__object/stdin"