On Thu, Aug 12, 2021 at 11:20 PM Philipp Rudo <prudo(a)redhat.com> wrote:
Hi Kairui,
On Thu, 12 Aug 2021 13:47:36 +0800
Kairui Song <kasong(a)redhat.com> wrote:
> Some `cat` calls are useless, remove them to make it cleaner.
add a reference to
https://github.com/koalaman/shellcheck/wiki/SC2002 ?
Good idea.
> Signed-off-by: Kairui Song <kasong(a)redhat.com>
> ---
> dracut-module-setup.sh | 6 ++++--
> kdumpctl | 22 ++++++++++++----------
> mkdumprd | 2 +-
> 3 files changed, 17 insertions(+), 13 deletions(-)
>
[...]
> diff --git a/kdumpctl b/kdumpctl
> index a4c257be..904f4bb7 100755
> --- a/kdumpctl
> +++ b/kdumpctl
[...]
> @@ -832,8 +831,11 @@ propagate_ssh_key()
>
> show_reserved_mem()
> {
> - local mem=$(cat /sys/kernel/kexec_crash_size)
> - local mem_mb=$(expr $mem / 1024 / 1024)
> + local mem
> + local mem_mb
> +
> + mem=$(</sys/kernel/kexec_crash_size)
> + mem_mb=$(expr "$mem" / 1024 / 1024)
Not actually part of the patch but the mem_mb variable is superfluous.
I think we can just keep it, it may help make the code easier to read.
[...]
> diff --git a/mkdumprd b/mkdumprd
> index de4e9944..60c2fa05 100644
> --- a/mkdumprd
> +++ b/mkdumprd
> @@ -331,7 +331,7 @@ is_unresettable()
>
> if [ -f "$path" ]
> then
> - resettable="$(cat $path)"
> + resettable="$(<path)"
^^^^
$path !
Thanks, good catch!
--
Best Regards,
Kairui Song