Skip to content

Commit 6f7fbb8

Browse files
prudo1coiby
authored andcommitted
kdumpctl/test: fix shellcheck findings
This commit fixes ShellCheck findings in kdumpctl introduced by the kdumpct test rewrite. In particular it fixes the following In kdumpctl line 192: _ret=$? ^--^ SC2178 (warning): Variable was used as an array but is now assigned a string. In kdumpctl line 195: return $_ret ^---^ SC2128 (warning): Expanding an array without an index only gives the first element. In kdumpctl line 1692: if [[ "$?" -ne 0 ]]; then ^--^ SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. In kdumpctl line 1739: mkdir -p $TMPMNT ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: mkdir -p "$TMPMNT" In kdumpctl line 1841: read -p "DANGER!!! Will perform a kdump test by crashing the system, proceed? (y/N): " input ^--^ SC2162 (info): read without -r will mangle backslashes. Fixes: 24e7622 ("Re-introduce vmcore creation notification to kdump") Signed-off-by: Philipp Rudo <[email protected]>
1 parent 23456a8 commit 6f7fbb8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kdumpctl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ rebuild_kdump_initrd()
176176

177177
rebuild_initrd()
178178
{
179+
local _ret
180+
179181
dinfo "Rebuilding $TARGET_INITRD"
180182

181183
if [[ ! -w $(dirname "$TARGET_INITRD") ]]; then
@@ -1687,9 +1689,8 @@ set_kdump_test_id()
16871689
local _id=$1
16881690

16891691
KDUMP_COMMANDLINE_APPEND+=" $_id "
1690-
reload >& /dev/null
16911692

1692-
if [[ "$?" -ne 0 ]]; then
1693+
if ! reload >& /dev/null; then
16931694
derror "Set kdump test id fail."
16941695
exit 1
16951696
fi
@@ -1736,7 +1737,7 @@ fetch_status()
17361737
if is_nfs_dump_target || is_local_target; then
17371738
_mnt=$(get_mntpoint_from_target "${OPT[_target]}")
17381739
if [[ -z "$_mnt" ]] || ! is_mounted "$_mnt"; then
1739-
mkdir -p $TMPMNT
1740+
mkdir -p "$TMPMNT"
17401741
mount "${OPT[_target]}" "$TMPMNT" -t "${OPT[_fstype]}" -o defaults || \
17411742
{ dwarn "Failed to mount ${OPT[_target]}" && return 2; }
17421743
_mnt="$TMPMNT"
@@ -1838,7 +1839,7 @@ kdump_test()
18381839
fi
18391840

18401841
if [[ ! "$1" == "--force" ]]; then
1841-
read -p "DANGER!!! Will perform a kdump test by crashing the system, proceed? (y/N): " input
1842+
read -r -p "DANGER!!! Will perform a kdump test by crashing the system, proceed? (y/N): " input
18421843
case $input in
18431844
[Yy] )
18441845
dinfo "Start kdump test..."

0 commit comments

Comments
 (0)