Skip to content

Commit c4582a3

Browse files
committed
go-xcat: Fix SC2124,SC2006,SC2086,SC2002,SC2016
Signed-off-by: Samveen <[email protected]>
1 parent 0c9373b commit c4582a3

File tree

1 file changed

+44
-44
lines changed
  • xCAT-server/share/xcat/tools

1 file changed

+44
-44
lines changed

xCAT-server/share/xcat/tools/go-xcat

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -681,58 +681,58 @@ function check_repo_version_dnf()
681681
# If a package has multiple versions, more work needs to be done.
682682
else
683683
# Get the current version of the package.
684-
current_version=`rpm -q --qf '%{version}-%{release}\n' $1`
684+
current_version=$(rpm -q --qf '%{version}-%{release}\n' "$1")
685685
686686
# Is xCAT currently installed?
687-
is_xcat_installed=`rpm -qa | grep -i xcat`
687+
is_xcat_installed=$(rpm -qa | grep -i xcat)
688688
689689
# If xCAT has not been installed yet.
690690
if [[ -z $is_xcat_installed ]]
691691
then
692692
# Use "dnf install" to gather more data about the package.
693-
dnf -v install $1 --assumeno 2> /tmp/$1-err 1> /tmp/$1-1
694-
tmp_result=`grep $1 /tmp/$1-1 | grep -v Installing`
693+
dnf -v install "$1" --assumeno 2> /tmp/"$1"-err 1> /tmp/"$1"-1
694+
tmp_result=$(grep "$1" /tmp/"$1"-1 | grep -v Installing)
695695
696696
# If the output does not have the word "Installing".
697697
if [[ -z $tmp_result ]]
698698
then
699699
# Parse the $1-err file.
700-
grep $1 /tmp/$1-err | head -1 | awk '{print $9}' > /tmp/$1-2
700+
grep "$1" /tmp/"$1"-err | head -1 | awk '{print $9}' > /tmp/"$1"-2
701701
# The string may have an epoch number at the front and arch at the end.
702702
# cut, sed and rev are used to get the version only.
703-
cat /tmp/$1-2 | cut -d ":" -f2 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
703+
cut -d ":" -f2 /tmp/"$1"-2 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
704704
else
705705
# If the output has the word "Installing", remove the epoch number as needed.
706-
grep $1 /tmp/$1-1 | grep -v installed | awk '{print $3}' | cut -d ":" -f2
706+
grep "$1" /tmp/"$1"-1 | grep -v installed | awk '{print $3}' | cut -d ":" -f2
707707
fi
708708
709709
# Remove temporary files.
710-
rm -f /tmp/$1-1 /tmp/$1-2 /tmp/$1-err
710+
rm -f /tmp/"$1"-1 /tmp/"$1"-2 /tmp/"$1"-err
711711
# If xCAT has been installed.
712712
else
713713
# Use "dnf update" to gather more data about the package.
714-
dnf -v update $1 --assumeno 2> /tmp/$1-err 1> /tmp/$1-1
715-
grep " $1\." /tmp/$1-1 | grep "an upgrade" | grep -v None > /tmp/$1-2
714+
dnf -v update "$1" --assumeno 2> /tmp/"$1"-err 1> /tmp/"$1"-1
715+
grep " $1\." /tmp/"$1"-1 | grep "an upgrade" | grep -v None > /tmp/"$1"-2
716716
717717
# If the output has the word "upgrade".
718-
if [[ -s /tmp/$1-2 ]]
718+
if [[ -s /tmp/"$1"-2 ]]
719719
then
720-
awk '{print $4}' /tmp/$1-2 | cut -d ":" -f2
720+
awk '{print $4}' /tmp/"$1"-2 | cut -d ":" -f2
721721
else
722-
grep "Nothing to do" /tmp/$1-1 > /tmp/$1-3
722+
grep "Nothing to do" /tmp/"$1"-1 > /tmp/"$1"-3
723723
# If the output has the phrase "Nothing to do", then just return the
724724
# current version.
725-
if [[ -s /tmp/$1-3 ]]
725+
if [[ -s /tmp/"$1"-3 ]]
726726
then
727-
echo $current_version
727+
echo "$current_version"
728728
else
729729
# Else, parse the $1-err file.
730-
grep $1 /tmp/$1-err | head -1 | awk '{print $10}' > /tmp/$1-4
731-
cat /tmp/$1-4 | cut -d ":" -f2 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
730+
grep "$1" /tmp/"$1"-err | head -1 | awk '{print $10}' > /tmp/"$1"-4
731+
cut -d ":" -f2 /tmp/"$1"-4 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
732732
fi
733733
fi
734734
# Remove temporary files.
735-
rm -f /tmp/$1-1 /tmp/$1-2 /tmp/$1-3 /tmp/$1-4 /tmp/$1-err
735+
rm -f /tmp/"$1"-1 /tmp/"$1"-2 /tmp/"$1"-3 /tmp/"$1"-4 /tmp/"$1"-err
736736
fi
737737
fi
738738
shift
@@ -803,58 +803,58 @@ function check_repo_version_yum()
803803
# If a package has multiple versions, more work needs to be done.
804804
else
805805
# Get the current version of the package.
806-
current_version=`rpm -q --qf '%{version}-%{release}\n' $1`
806+
current_version=$(rpm -q --qf '%{version}-%{release}\n' "$1")
807807
808808
# Is xCAT currently installed?
809-
is_xcat_installed=`rpm -qa | grep -i xcat`
809+
is_xcat_installed=$(rpm -qa | grep -i xcat)
810810
811811
# If xCAT has not been installed yet.
812812
if [[ -z $is_xcat_installed ]]
813813
then
814814
# Use "yum install" to gather more data about the package.
815-
yum -v install $1 --assumeno 2> /tmp/$1-err 1> /tmp/$1-1
816-
tmp_result=`grep $1 /tmp/$1-1 | grep -v Installing`
815+
yum -v install "$1" --assumeno 2> /tmp/"$1"-err 1> /tmp/"$1"-1
816+
tmp_result=$(grep "$1" /tmp/"$1"-1 | grep -v Installing)
817817
818818
# If the output does not have the word "Installing".
819819
if [[ -z $tmp_result ]]
820820
then
821821
# Parse the $1-err file.
822-
grep $1 /tmp/$1-err | head -1 | awk '{print $9}' > /tmp/$1-2
822+
grep "$1" /tmp/"$1"-err | head -1 | awk '{print $9}' > /tmp/"$1"-2
823823
# The string may have an epoch number at the front and arch at the end.
824824
# cut, sed and rev are used to get the version only.
825-
cat /tmp/$1-2 | cut -d ":" -f2 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
825+
cut -d ":" -f2 /tmp/"$1"-2 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
826826
else
827827
# If the output has the word "Installing", remove the epoch number as needed.
828-
grep $1 /tmp/$1-1 | grep -v installed | awk '{print $3}' | cut -d ":" -f2
828+
grep "$1" /tmp/"$1"-1 | grep -v installed | awk '{print $3}' | cut -d ":" -f2
829829
fi
830830
831831
# Remove temporary files.
832-
rm -f /tmp/$1-1 /tmp/$1-2 /tmp/$1-err
832+
rm -f /tmp/"$1"-1 /tmp/"$1"-2 /tmp/"$1"-err
833833
# If xCAT has been installed.
834834
else
835835
# Use "yum update" to gather more data about the package.
836-
yum -v update $1 --assumeno 2> /tmp/$1-err 1> /tmp/$1-1
837-
grep " $1\." /tmp/$1-1 | grep "an upgrade" | grep -v None > /tmp/$1-2
836+
yum -v update "$1" --assumeno 2> /tmp/"$1"-err 1> /tmp/"$1"-1
837+
grep " $1\." /tmp/"$1"-1 | grep "an upgrade" | grep -v None > /tmp/"$1"-2
838838
839839
# If the output has the word "upgrade".
840-
if [[ -s /tmp/$1-2 ]]
840+
if [[ -s /tmp/"$1"-2 ]]
841841
then
842-
awk '{print $4}' /tmp/$1-2 | cut -d ":" -f2
842+
awk '{print $4}' /tmp/"$1"-2 | cut -d ":" -f2
843843
else
844-
grep "Nothing to do" /tmp/$1-1 > /tmp/$1-3
844+
grep "Nothing to do" /tmp/"$1"-1 > /tmp/"$1"-3
845845
# If the output has the phrase "Nothing to do", then just return the
846846
# current version.
847-
if [[ -s /tmp/$1-3 ]]
847+
if [[ -s /tmp/"$1"-3 ]]
848848
then
849-
echo $current_version
849+
echo "$current_version"
850850
else
851851
# Else, parse the $1-err file.
852-
grep $1 /tmp/$1-err | head -1 | awk '{print $10}' > /tmp/$1-4
853-
cat /tmp/$1-4 | cut -d ":" -f2 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
852+
grep "$1" /tmp/"$1"-err | head -1 | awk '{print $10}' > /tmp/"$1"-4
853+
cut -d ":" -f2 /tmp/"$1"-4 | rev | sed s/[.]/:/ | cut -d ":" -f2 | rev
854854
fi
855855
fi
856856
# Remove temporary files.
857-
rm -f /tmp/$1-1 /tmp/$1-2 /tmp/$1-3 /tmp/$1-4 /tmp/$1-err
857+
rm -f /tmp/"$1"-1 /tmp/"$1"-2 /tmp/"$1"-3 /tmp/"$1"-4 /tmp/"$1"-err
858858
fi
859859
fi
860860
shift
@@ -1755,7 +1755,7 @@ function github_issue_6525_workaround()
17551755
# Check for EPEL and CRB repositories when installing on RH family of OSes
17561756
function el9_epel_and_crb_check()
17571757
{
1758-
action="$@" # Passed parameter will only be 'yum' or 'dnf'
1758+
action="$*" # Passed parameter will only be 'yum' or 'dnf'
17591759
if [[ "${GO_XCAT_LINUX_DISTRO}" = "fedora" ]]
17601760
then
17611761
# For Fedora, version 35 is equivalent to EL9
@@ -1766,7 +1766,7 @@ function el9_epel_and_crb_check()
17661766
else
17671767
[[ "${GO_XCAT_LINUX_VERSION}" =~ ^9(\.[0-9]) ]] || return 0
17681768
fi
1769-
${action} list -q ${EL9_EPEL_TEST_RPM}
1769+
${action} list -q "${EL9_EPEL_TEST_RPM}"
17701770
ret="$?"
17711771
case "${ret}" in
17721772
"1")
@@ -1777,7 +1777,7 @@ Installation on ${GO_XCAT_LINUX_DISTRO} ${GO_XCAT_LINUX_VERSION} requires EPEL r
17771777
exit 1
17781778
;;
17791779
esac
1780-
${action} list -q ${EL9_CRB_TEST_RPM}
1780+
${action} list -q "${EL9_CRB_TEST_RPM}"
17811781
ret="$?"
17821782
case "${ret}" in
17831783
"1")
@@ -1787,8 +1787,8 @@ Installation on ${GO_XCAT_LINUX_DISTRO} ${GO_XCAT_LINUX_VERSION} requires CRB re
17871787
echo "Try adding the following entries to new or existing '.repo' file:"
17881788
echo "
17891789
[crb]
1790-
name=CentOS Stream $releasever - CRB
1791-
metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http
1790+
name=CentOS Stream \$releasever - CRB
1791+
metalink=https://mirrors.centos.org/metalink?repo=centos-crb-\$stream&arch=\$basearch&protocol=https,http
17921792
gpgcheck=0
17931793
repo_gpgcheck=0
17941794
metadata_expire=6h
@@ -1865,7 +1865,7 @@ function remove_package_apt()
18651865
# For each package, remove one at a time
18661866
for package in "$@"
18671867
do
1868-
apt-get --allow-unauthenticated remove "${yes[@]}" ${package}
1868+
apt-get --allow-unauthenticated remove "${yes[@]}" "${package}"
18691869
warn_if_bad "$?" "Unable to remove xCAT package ${package}"
18701870
done
18711871
}
@@ -1884,7 +1884,7 @@ function purge_package_apt()
18841884
# For each package, remove one at a time
18851885
for package in "$@"
18861886
do
1887-
apt-get --allow-unauthenticated purge "${yes[@]}" ${package}
1887+
apt-get --allow-unauthenticated purge "${yes[@]}" "${package}"
18881888
warn_if_bad "$?" "Unable to purge xCAT package ${package}"
18891889
done
18901890
}
@@ -2139,7 +2139,7 @@ function test_case_001_xcatd()
21392139
warn_if_bad "$?" "${f}: no such file" || continue
21402140
21412141
kill -0 "$(<"${f}")" >/dev/null 2>&1
2142-
warn_if_bad "$?" "Process with an ID $(<${f}) is not running"
2142+
warn_if_bad "$?" "Process with an ID $(<"${f}") is not running"
21432143
(( ret += $? ))
21442144
done
21452145

0 commit comments

Comments
 (0)