lynis icon indicating copy to clipboard operation
lynis copied to clipboard

SC2240 (warning): The dot command does not support arguments in sh/dash

Open wileyhy opened this issue 1 year ago • 0 comments

Describe the bug ** # shellcheck -s sh -S warning /usr/bin/lynis

In /usr/bin/lynis line 1095: . ${INCLUDEDIR}/helper_${HELPER} ${HELPER_PARAMS} ^--------------^ SC2240 (warning): The dot command does not support arguments in sh/dash. Set them as variables.

** This text, from https://www.shellcheck.net/wiki/SC2240:

Problematic code:

#!/bin/sh . include/myscript example.com 80

Correct code:

#!/bin/sh host=example.com port=80 . include/myscript

Rationale: In Bash and Ksh, you can use . myscript arg1 arg2.. to set $1 and $2 in the sourced script. This is not the case in Dash, where any additional arguments are ignored, or in POSIX sh where the behavior is unspecified. Instead, assign arguments to variables and rewrite the sourced script to read from them.

Version Distribution: Fedora 38

** # uname -a

Linux localhost-live 6.2.9-300.fc38.x86_64 https://github.com/CISOfy/lynis/issues/1 SMP PREEMPT_DYNAMIC Thu Mar 30 22:32:58 UTC 2023 x86_64 GNU/Linux

** # lynis --version

egrep: warning: egrep is obsolescent; using grep -E
egrep: warning: egrep is obsolescent; using grep -E
3.0.8

Expected behavior No warnings.

wileyhy avatar Jun 23 '23 17:06 wileyhy