Change backslash-dquote to single quote

Slightly breaking change, but improves security and readability.
This commit is contained in:
Jonas Weber 2018-10-03 19:38:47 +02:00
parent ae7ccc5995
commit 53728a7ff0
18 changed files with 64 additions and 64 deletions

View file

@ -29,9 +29,9 @@ fi
case "$state_should" in
present)
echo "add-apt-repository \"$name\""
echo "add-apt-repository '$name'"
;;
absent)
echo "remove-apt-repository \"$name\""
echo "remove-apt-repository '$name'"
;;
esac

View file

@ -42,18 +42,18 @@ get_current_value() {
}
set_group() {
echo chgrp \""$1"\" \""$destination"\"
echo chgrp "$1" >> "$__messages_out"
echo "chgrp '$1' '$destination'"
echo "chgrp '$1'" >> "$__messages_out"
}
set_owner() {
echo chown \""$1"\" \""$destination"\"
echo chown "$1" >> "$__messages_out"
echo "chown '$1' '$destination'"
echo "chown '$1'" >> "$__messages_out"
}
set_mode() {
echo chmod \""$1"\" \""$destination"\"
echo chmod "$1" >> "$__messages_out"
echo "chmod '$1' '$destination'"
echo "chmod '$1'" >> "$__messages_out"
}
set_attributes=
@ -81,7 +81,7 @@ case "$state_should" in
absent)
if [ "$type" = "file" ]; then
echo rm -f \""$destination"\"
echo "rm -f '$destination'"
echo remove >> "$__messages_out"
fi
;;

View file

@ -57,18 +57,18 @@ get_current_value() {
}
set_group() {
echo chgrp "$recursive" \""$1"\" \""$destination"\"
echo chgrp "$recursive" "$1" >> "$__messages_out"
echo "chgrp '$recursive' '$1' '$destination'"
echo "chgrp '$recursive' '$1'" >> "$__messages_out"
}
set_owner() {
echo chown "$recursive" \""$1"\" \""$destination"\"
echo chown "$recursive" "$1" >> "$__messages_out"
echo "chown '$recursive' '$1' '$destination'"
echo "chown '$recursive' '$1'" >> "$__messages_out"
}
set_mode() {
echo chmod "$recursive" \""$1"\" \""$destination"\"
echo chmod "$recursive" "$1" >> "$__messages_out"
echo "chmod '$recursive' '$1' '$destination'"
echo "chmod '$recursive' '$1'" >> "$__messages_out"
}
case "$state_should" in
@ -78,10 +78,10 @@ case "$state_should" in
if [ "$type" != "none" ]; then
# our destination is not a directory, remove whatever is there
# and then create our directory and set all attributes
echo rm -f "\"$destination\""
echo "rm -f '$destination'"
echo "remove non directory" >> "$__messages_out"
fi
echo "mkdir $mkdiropt \"$destination\""
echo "mkdir $mkdiropt '$destination'"
echo "create" >> "$__messages_out"
fi
@ -105,7 +105,7 @@ case "$state_should" in
;;
absent)
if [ "$type" = "directory" ]; then
echo rm -rf \""$destination"\"
echo "rm -rf '$destination'"
echo remove >> "$__messages_out"
fi
;;

View file

@ -43,18 +43,18 @@ get_current_value() {
}
set_group() {
echo chgrp \""$1"\" \""$destination"\"
echo chgrp "$1" >> "$__messages_out"
echo "chgrp '$1' '$destination'"
echo "chgrp '$1'" >> "$__messages_out"
}
set_owner() {
echo chown \""$1"\" \""$destination"\"
echo chown "$1" >> "$__messages_out"
echo "chown '$1' '$destination'"
echo "chown '$1'" >> "$__messages_out"
}
set_mode() {
echo chmod \""$1"\" \""$destination"\"
echo chmod "$1" >> "$__messages_out"
echo "chmod '$1' '$destination'"
echo "chmod '$1'" >> "$__messages_out"
}
set_attributes=
@ -82,7 +82,7 @@ case "$state_should" in
absent)
if [ "$type" = "file" ]; then
echo rm -f \""$destination"\"
echo "rm -f '$destination'"
echo remove >> "$__messages_out"
fi
;;

View file

@ -33,13 +33,13 @@ rule="$(cat "$__object/parameter/rule")"
case "$state_should" in
present)
echo "firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule"
echo "firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule"
echo "firewall-cmd --quiet --permanent --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule"
echo "firewall-cmd --quiet --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule"
;;
absent)
echo "firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule"
echo "firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule"
echo "firewall-cmd --quiet --permanent --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule"
echo "firewall-cmd --quiet --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule"
;;
*)
echo "Unknown state $state_should" >&2

View file

@ -85,7 +85,7 @@ primary_count=0
for object in $objects; do
device="$(cat "$object/parameter/device")"
if [ "$current_device" != "$device" ]; then
echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'"
echo "create_disklabel '$device' || die 'Failed to create disklabel for $device'"
current_device="$device"
device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g')
available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))

View file

@ -77,11 +77,11 @@ case "$state_should" in
if [ -n "$version" ]; then
name="${name}=${version}"
fi
echo "$aptget install $target_release \"$name\""
echo "$aptget install $target_release '$name'"
echo "installed" >> "$__messages_out"
;;
absent)
echo "$aptget remove $purgeparam \"$name\""
echo "$aptget remove $purgeparam '$name'"
echo "removed" >> "$__messages_out"
;;
*)

View file

@ -63,10 +63,10 @@ fi
case "$state_should" in
present)
echo "emerge \"$name\" &>/dev/null || exit 1"
echo "emerge '$name' &>/dev/null || exit 1"
;;
absent)
echo "emerge -C \"$name\" &>/dev/null || exit 1"
echo "emerge -C '$name' &>/dev/null || exit 1"
;;
*)
echo "Unknown state: $state_should" >&2

View file

@ -42,10 +42,10 @@ fi
case "$state_should" in
present)
echo luarocks install \""$name"\"
echo "luarocks install '$name'"
;;
absent)
echo luarocks remove \""$name"\"
echo "luarocks remove '$name'"
;;
*)
echo "Unknown state: $state_should" >&2

View file

@ -45,10 +45,10 @@ case "$state_should" in
if [ "$present" = "notpresent" ]; then
echo opkg --verbosity=0 update
fi
echo opkg --verbosity=0 install \""$name"\"
echo "opkg --verbosity=0 install '$name'"
;;
absent)
echo opkg --verbosity=0 remove \""$name"\"
echo "opkg --verbosity=0 remove '$name'"
;;
*)
echo "Unknown state: $state" >&2

View file

@ -45,10 +45,10 @@ fi
case "$state_should" in
present)
echo pacman --needed --noconfirm --noprogressbar -S \""$name"\"
echo "pacman --needed --noconfirm --noprogressbar -S '$name'"
;;
absent)
echo pacman --noconfirm --noprogressbar -R \""$name"\"
echo "pacman --noconfirm --noprogressbar -R '$name'"
;;
*)
echo "Unknown state: $state_should" >&2

View file

@ -53,7 +53,7 @@ case "$state_should" in
present)
if [ "$runas" ]
then
echo "su -c \"$pip install -q $name\" $runas"
echo "su -c '$pip install -q $name' $runas"
else
echo $pip install -q "$name"
fi
@ -61,7 +61,7 @@ case "$state_should" in
absent)
if [ "$runas" ]
then
echo "su -c \"$pip uninstall -q -y $name\" $runas"
echo "su -c '$pip uninstall -q -y $name' $runas"
else
echo $pip uninstall -q -y "$name"
fi

View file

@ -39,10 +39,10 @@ fi
case "$state_should" in
present)
echo gem install \""$name"\" --no-ri --no-rdoc
echo "gem install '$name' --no-ri --no-rdoc"
;;
absent)
echo gem uninstall \""$name"\"
echo "gem uninstall '$name'"
;;
*)
echo "Unknown state: $state_should" >&2

View file

@ -60,10 +60,10 @@ fi
case "$state_should" in
present)
echo "yum $opts install \"$install_name\""
echo "yum $opts install '$install_name'"
;;
absent)
echo "yum $opts remove \"$name\""
echo "yum $opts remove '$name'"
;;
*)
echo "Unknown state: $state_should" >&2

View file

@ -61,15 +61,15 @@ case "$state_should" in
present)
if [ -z "$version_should" ]; then
[ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything
echo "zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" >/dev/null"
echo "zypper $globalopts install --type '$ptype' --auto-agree-with-licenses '$name' >/dev/null"
else
[ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything
echo "zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" >/dev/null"
echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null"
fi
;;
absent)
[ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything
echo "zypper $globalopts remove --type \"$ptype\" \"$name\" >/dev/null"
echo "zypper $globalopts remove --type '$ptype' '$name' >/dev/null"
;;
*)
echo "Unknown state: $state_should" >&2

View file

@ -18,4 +18,4 @@ format="$(cat "$__object/parameter/format")"
size="$(cat "$__object/parameter/size")"
diskimage="/$__object_id"
echo "qemu-img create -f \"$format\" \"$diskimage\" \"$size\""
echo "qemu-img create -f '$format' '$diskimage' '$size'"

View file

@ -37,16 +37,16 @@ case "$state_should" in
if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl -q enable \"$name\""
echo "systemctl -q enable '$name'"
else
case "$os" in
debian)
case "$os_version" in
[1-7]*)
echo "update-rc.d \"$name\" defaults >/dev/null"
echo "update-rc.d '$name' defaults >/dev/null"
;;
8*)
echo "systemctl enable \"$name\""
echo "systemctl enable '$name'"
;;
*)
echo "Unsupported version $os_version of $os" >&2
@ -55,26 +55,26 @@ case "$state_should" in
esac
;;
devuan)
echo "update-rc.d \"$name\" defaults >/dev/null"
echo "update-rc.d '$name' defaults >/dev/null"
;;
gentoo)
echo "rc-update add \"$name\" \"$target_runlevel\""
echo "rc-update add '$name' '$target_runlevel'"
;;
amazon|scientific|centos|fedora|owl|redhat|suse)
echo "chkconfig \"$name\" on"
echo "chkconfig '$name' on"
;;
openwrt)
# 'enable' can be successful and still return a non-zero exit
# code, deal with it by checking for success ourselves in that
# case (the || ... part).
echo "/etc/init.d/\"$name\" enable || [ -f /etc/rc.d/S??\"$name\" ]"
echo "'/etc/init.d/$name' enable || [ -f /etc/rc.d/S??'$name' ]"
;;
ubuntu)
echo "update-rc.d \"$name\" defaults >/dev/null"
echo "update-rc.d '$name' defaults >/dev/null"
;;
freebsd)
@ -93,24 +93,24 @@ case "$state_should" in
if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl -q disable \"$name\""
echo "systemctl -q disable '$name'"
else
case "$os" in
debian|ubuntu|devuan)
echo "update-rc.d -f \"$name\" remove"
echo "update-rc.d -f '$name' remove"
;;
gentoo)
echo "rc-update del \"$name\" \"$target_runlevel\""
echo "rc-update del '$name' '$target_runlevel'"
;;
centos|fedora|owl|redhat|suse)
echo "chkconfig \"$name\" off"
echo "chkconfig '$name' off"
;;
openwrt)
echo "\"/etc/init.d/$name\" disable"
echo "'/etc/init.d/$name' disable"
;;
*)

View file

@ -71,7 +71,7 @@ fi
case "$state_should" in
present)
echo "zypper $zypper_def_opts addservice -t $stype $uri \"$desc\""
echo "zypper $zypper_def_opts addservice -t $stype $uri '$desc'"
echo "zypper $zypper_def_opts refs"
echo "zypper $zypper_def_opts ref"
;;