Skip to content

Commit 22be70d

Browse files
VerdantE1superjamie
authored andcommitted
lint: fix shellcheck SC2068/SC2071
1 parent fb36744 commit 22be70d

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

xsos

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ Special options (BASH v4+ required):"
290290
--N=FILE❚read from FILE containing /proc/net/dev dump
291291
--G=FILE❚read from FILE containing /proc/net/bonding/xxx dump
292292
--I=FILE❚read from FILE containing \`ip addr\` dump
293-
--P=FILE❚read from FILE containing \`ps aux\` dump" | column -ts❚
293+
--P=FILE❚read from FILE containing \`ps aux\` dump
294+
--S=FILE❚read from FILE containing \`ss -peaonmi\` dump
295+
--F=FILE❚read from FILE containing \`systemctl_status_--all\` dump" | column -ts❚
294296
}
295297

296298
HELP_SHORT() {
@@ -478,12 +480,13 @@ PARSE() {
478480
--G) sfile[G]=$2; shift ;;
479481
--I) sfile[I]=$2; shift ;;
480482
--P) sfile[P]=$2; shift ;;
483+
--S) sfile[S]=$2; shift ;;
481484
esac
482485
shift
483486
done
484487
shift #(to get rid of the '--')
485488
# Set sosroot
486-
sosroot=$@
489+
sosroot="$@"
487490
}
488491

489492
# Call the parser
@@ -2171,7 +2174,7 @@ TEAMING() {
21712174
# If an sosreport, look for sos_commands/teamd/ output...
21722175
else
21732176
files=("$1"/sos_commands/teamd/teamdctl_*_state_dump)
2174-
if [[ ! -r ${files[0]} ]]; then
2177+
if [[ ! -r "${files[0]}" ]]; then
21752178
echo -e "${c[Warn2]}Warning:${c[Warn1]} '/sos_commands/teamd/teamdctl_*_state_dump' files unreadable; skipping teaming check${c[0]}" >&2
21762179
echo -en $XSOS_HEADING_SEPARATOR >&2
21772180
return
@@ -2193,7 +2196,7 @@ TEAMING() {
21932196
echo " Device❚Runner (mode) ❚ifcfg-File TEAM_CONFIG❚Partner MAC Addr❚Ports (*=active; [n]=AggID)"
21942197
echo " ========❚=================❚========================❚==================❚==============================="
21952198

2196-
f=0; for team_input in ${files[@]}; do
2199+
f=0; for team_input in "${files[@]}"; do
21972200

21982201
team_name=$(gawk -F '"' '/team_device/,/^$/ {if ($2 == "ifname") {print $4}}' $team_input)
21992202
echo -n " $team_name"
@@ -2293,7 +2296,7 @@ BONDING() {
22932296
# If localhost or sosreport, use that
22942297
else
22952298
files=("$1"/proc/net/bonding/*)
2296-
if [[ ! -r ${files[0]} ]]; then
2299+
if [[ ! -r "${files[0]}" ]]; then
22972300
echo -e "${c[Warn2]}Warning:${c[Warn1]} '/proc/net/bonding/' files unreadable; skipping bonding check${c[0]}" >&2
22982301
echo -en $XSOS_HEADING_SEPARATOR >&2
22992302
return
@@ -2343,7 +2346,7 @@ BONDING() {
23432346
echo " Device❚Mode❚ifcfg-File BONDING_OPTS❚Partner MAC Addr❚Slaves (*=active; [n]=AggID)"
23442347
echo " ========❚=================❚========================❚==================❚==============================="
23452348

2346-
f=0; for bond_input in ${files[@]}; do
2349+
f=0; for bond_input in "${files[@]}"; do
23472350

23482351
echo -n " ${bond_input##*/}"
23492352

@@ -3379,7 +3382,7 @@ PSCHECK() {
33793382
fi
33803383

33813384
# Calculate top cpu-using & mem-using users
3382-
if [[ $XSOS_PS_LEVEL < 3 ]]; then # If verbosity level 0-2, restrict number of users shown
3385+
if [[ $XSOS_PS_LEVEL -lt 3 ]]; then # If verbosity level 0-2, restrict number of users shown
33833386
# Process ps input to generate summary user-list of top-users
33843387
top_users=$(
33853388
gawk -vu=$(tr '[:lower:]' '[:upper:]' <<<"$XSOS_PS_UNIT") '
@@ -3879,7 +3882,7 @@ NETSTAT(){
38793882
}
38803883
_print_proc_net_array(){
38813884
declare -A __array="$*"
3882-
for hdr in ${!__array[@]}; do
3885+
for hdr in "${!__array[@]}"; do
38833886
val="${__array[$hdr]}"
38843887
[ "${XSOS_NETSTAT_IGNORE_ZERO}" == "y" ] && [ "$val" -eq "0" ] && continue
38853888
[ "${XSOS_NETSTAT_FILTER_REGEX}" != "" ] && [[ ! ${hdr,,} =~ ${XSOS_NETSTAT_FILTER_REGEX,,} ]] && continue
@@ -3976,6 +3979,8 @@ trap "rm -rf $TMPDIR 2>/dev/null" EXIT
39763979
[[ -r ${sfile[G]} ]] && BONDING "${sfile[G]}"
39773980
[[ -r ${sfile[I]} ]] && IPADDR "${sfile[I]}"
39783981
[[ -r ${sfile[P]} ]] && PSCHECK "${sfile[P]}"
3982+
[[ -r ${sfile[S]} ]] && SSCHECK "${sfile[S]}"
3983+
[[ -r ${sfile[F]} ]] && FIREWALL "${sfile[F]}"
39793984

39803985
# If SOSREPORT-ROOT provided, use that
39813986
elif [[ -n $sosroot ]]; then

xsos-bash-completion.bash

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ _xsos() {
3636
-6 -q -u -v -w
3737
-x -y -z"
3838

39-
longopts="--help --version
40-
--all --bios --os --kdump --cpu --intrupt --mem --disks --mpath --lspci --ethtool --softirq --netdev --bonding --ip --net --sysctl --ps --ss --firewall --ifcfg --netstat
41-
--B --C --F --M --D --T --L --R --N --G --I --P
42-
--scrub --ipv6 --rhsupport --wwid --unit --threads --verbose --width
43-
--nocolor --less --more"
39+
longopts="--help --version
40+
--all --bios --os --kdump --cpu --intrupt --mem --disks --mpath --lspci --ethtool --softirq --netdev --bonding --ip --net --sysctl --ps -ss --firewall --ifcfg --netstat
41+
--B --C --F --M --D --T --L --R --N --G --I --P
42+
--scrub --ipv6 --wwid --unit --threads --verbose --width
43+
--nocolor --less --more"
4444

4545
# Check previous arg to see if we need to do anything special
4646
case "$prev" in

0 commit comments

Comments
 (0)