Ryan Harper has uploaded a new change for review.
Change subject: vdsmd: remove bashisms found with checkbashism script on ubuntu
......................................................................
vdsmd: remove bashisms found with checkbashism script on ubuntu
Ubuntu uses dash for its /bin/sh and some of the shell scripting
includes bashisms that come through even with bash --posix (aka
/bin/sh -> /bin/bash.
Most of the fixes fall into the following changes:
- Using '=' instead of '==' for comparison
- Using '[ ]' instead of '[[ ]]' for test
- replacing {..} with seq
The remaining bashisms are around emitting messages, updating these
would require moving to using gettext's shell helper for producing
intl. lang equivalents.
To find files in the repository that need scanning, I looked for files
with '/bin/sh' in the file, excluding non-shell script files. For each
of the files that filtered through, I ran checkbashisms to see if the
file needed a closer look.
% find . -type f | egrep -v
"(configure|build|aclocal|.py|Makefile|README|.git|autom4te.cache)" | xargs -i
grep -l "/bin/sh" {}
./scripts/make_device_config.sh
./scripts/create_config
./scripts/feature_to_c.sh
./scripts/hxtool
./scripts/signrom.sh
./scripts/tracetool
./scripts/qemu-binfmt-conf.sh
./scripts/update-linux-headers.sh
./scripts/check-qerror.sh
./vdsm/sudoers.vdsm.in
./vdsm/vdsm-logrotate
./vdsm/vdsmd.init.in
./autogen.sh
./vdsm_cli/vdsClient.in
./tests/run_tests.sh.in
./tests/run_tests_local.sh.in
./vdsm_reg/vdsm-reg-logrotate
(platechiller) vdsm % find . -type f | egrep -v
"(configure|build|aclocal|.py|Makefile|README|.git|autom4te.cache)" | xargs -i
grep -l "/bin/sh" {} | xargs -i bash -c 'P={}; checkbashisms $P &>/dev/null ||
echo $P'
./vdsm/vdsmd.init.in
Only vdsmd.init.in needed fixing.
Change-Id: Iece592e9cc3dfa361c99812461d783bff7f780a0
Signed-off-by: Ryan Harper <[email protected]>
---
M vdsm/vdsmd.init.in
1 file changed, 11 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/8336/1
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in
index 0012157..2c0e894 100755
--- a/vdsm/vdsmd.init.in
+++ b/vdsm/vdsmd.init.in
@@ -112,13 +112,13 @@
local listen_tcp auth_tcp ssl
ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
- [ "$ssl" == true ] && return 0
+ [ "$ssl" = "true" ] && return 0
listen_tcp="`get_libvirt_conf_item $LCONF listen_tcp`"
auth_tcp="`get_libvirt_conf_item $LCONF auth_tcp`"
spice_tls="`get_libvirt_conf_item $QCONF spice_tls`"
- if [ "$listen_tcp" == 1 -a "$auth_tcp" == '"none"' -a "$spice_tls" == 0 ];
+ if [ "$listen_tcp" = "1" -a "$auth_tcp" = '"none"' -a "$spice_tls" = "0" ];
then
return 0
else
@@ -138,7 +138,7 @@
/sbin/chkconfig $srv off
if /sbin/service $srv status > /dev/null 2>&1;
then
- if [ "$srv" == "libvirt-guests" ]; then
+ if [ "$srv" = "libvirt-guests" ]; then
/bin/rm -f /var/lock/subsys/libvirt-guests
else
/sbin/service $srv stop
@@ -149,7 +149,7 @@
}
libvirt_should_use_upstart() {
- [[ -x /sbin/initctl ]]
+ [ -x /sbin/initctl ]
}
start_needed_srv() {
@@ -297,7 +297,7 @@
set_if_default $lconf host_uuid \"$(uuidgen)\"
set_if_default $qconf dynamic_ownership 0
- if [[ "$ssl" == true ]]; then
+ if [ "$ssl" = "true" ]; then
set_if_default $qconf spice_tls 1
else
set_if_default $qconf spice_tls 0
@@ -314,7 +314,7 @@
if [ -f $ts/certs/cacert.pem -a \
-f $ts/certs/vdsmcert.pem -a \
-f $ts/keys/vdsmkey.pem -a \
- "$ssl" == true ];
+ "$ssl" = "true" ];
then
set_if_default $lconf ca_file \"$ts/certs/cacert.pem\"
set_if_default $lconf cert_file \"$ts/certs/vdsmcert.pem\"
@@ -389,7 +389,7 @@
stop_libvirtd_sysv() {
# stop libvirt SysV service if we intend to configure upstart
- if libvirt_should_use_upstart && ! [[ -f /etc/init/libvirtd.conf ]]; then
+ if libvirt_should_use_upstart && ! [ -f /etc/init/libvirtd.conf ]; then
/sbin/chkconfig libvirtd off
/sbin/service libvirtd stop
fi
@@ -400,7 +400,7 @@
# its socket is not yet ready. Once issue fixed on libvirt,
# this workaround should be removed.
- for i in {1..50}
+ for i in $(seq 1 50)
do
if /usr/bin/virsh -r version > /dev/null 2>&1; then
return 0
@@ -426,14 +426,14 @@
/bin/grep libvirtd.upstart | /usr/bin/tail -1`
target=/etc/init/libvirtd.conf
- if [[ -f "$packaged" ]] && ! diff -q "$packaged" "$target" >/dev/null;
+ if [ -f "$packaged" ] && ! diff -q "$packaged" "$target" >/dev/null;
then
/bin/cp -p "$packaged" "$target" || return 1
/sbin/initctl reload-configuration
fi
startout=`/sbin/initctl start libvirtd 2>&1`
- if [[ "$?" -eq 0 || "$startout" =~ .*already\ running.* ]];
+ if [ "$?" -eq 0 || "$startout" =~ .*already\ running.* ];
then
await_libvirt_start_workaround
return 0
@@ -480,7 +480,7 @@
mk_dom_backup
mk_run_path
/bin/chmod 1777 /dev/shm
- if [ $is_coredump == true ]; then
+ if [ $is_coredump = "true" ]; then
export DAEMON_COREFILE_LIMIT=unlimited
echo $CORE_DUMP_PATH > $CORE_PATTERN
fi
--
To view, visit http://gerrit.ovirt.org/8336
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iece592e9cc3dfa361c99812461d783bff7f780a0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ryan Harper <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches