Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wileyhy opened this issue Jun 23, 2023 · 0 comments
Open

Comments

@wileyhy
Copy link

wileyhy commented Jun 23, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant