kdumpctl: refine grep usage

upstream: fedora
resolves: bz2003832
conflict: none

commit 80525afaceac3fa6bdf6e57686f66ab497d2f153
Author: Kairui Song <kasong@redhat.com>
Date:   Wed Aug 4 15:44:02 2021 +0800

    kdumpctl: refine grep usage

    Use `grep -q` instead of redirect to /dev/null.

    Use `grep -c` instead, as suggested in:
    https://github.com/koalaman/shellcheck/wiki/SC2126

    Use `grep -E` instead of `egrep`.
    https://github.com/koalaman/shellcheck/wiki/SC2196

    Signed-off-by: Kairui Song <kasong@redhat.com>

Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
Tao Liu 2021-11-03 15:29:36 +08:00
parent 6c43817d23
commit e35e4054ca
1 changed files with 5 additions and 5 deletions

View File

@ -506,7 +506,7 @@ check_fs_modified()
# if --mount argument present then match old and new target, mount
# point and file system. If any of them mismatches then rebuild
echo $_dracut_args | grep "\-\-mount" &> /dev/null
echo $_dracut_args | grep -q "\-\-mount"
if [[ $? -eq 0 ]];then
set -- $(echo $_dracut_args | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3)
_old_dev=$1
@ -596,7 +596,7 @@ check_rebuild()
#in case of fadump mode, check whether the default/target
#initrd is already built with dump capture capability
if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE $TARGET_INITRD | grep -e ^kdumpbase$ -e ^zz-fadumpinit$ | wc -l)
capture_capable_initrd=$(lsinitrd -f $DRACUT_MODULES_FILE "$TARGET_INITRD" | grep -c -e ^kdumpbase$ -e ^zz-fadumpinit$)
fi
fi
@ -729,7 +729,7 @@ check_and_wait_network_ready()
# if server removes the authorized_keys or, no /root/.ssh/kdump_id_rsa
ddebug "$errmsg"
echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed" &> /dev/null
echo $errmsg | grep -q "Permission denied\|No such file or directory\|Host key verification failed"
if [ $? -eq 0 ]; then
derror "Could not create $DUMP_TARGET:$SAVE_PATH, you probably need to run \"kdumpctl propagate\""
return 1
@ -869,7 +869,7 @@ local_fs_dump_target()
{
local _target
_target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf)
_target=$(grep -E "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf)
if [ $? -eq 0 ]; then
echo $_target|awk '{print $2}'
fi
@ -932,7 +932,7 @@ check_fence_kdump_config()
return 1
fi
# node can be ipaddr
echo "$ipaddrs " | grep "$node " > /dev/null
echo "$ipaddrs " | grep -q "$node "
if [ $? -eq 0 ]; then
derror "Option fence_kdump_nodes cannot contain $node"
return 1