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

RFE: variant of source= directive that supports globbing #2985

Open
2 tasks done
intelfx opened this issue May 16, 2024 · 0 comments
Open
2 tasks done

RFE: variant of source= directive that supports globbing #2985

intelfx opened this issue May 16, 2024 · 0 comments

Comments

@intelfx
Copy link

intelfx commented May 16, 2024

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

There is a pattern common to relatively large shell programs of loading multiple files with subroutines from a "library" directory, e.g.:

MAKEPKG_LIBRARY=${MAKEPKG_LIBRARY:-'@libmakepkgdir@'}

# Import libmakepkg
for lib in "$MAKEPKG_LIBRARY"/*.sh; do
	source "$lib"
done

Here's what shellcheck currently says:

Shellcheck gives a single SC1090 at the source site, which is expected:

ShellCheck can't follow non-constant source. Use a directive to specify location.

However, this is not helpful because a source= directive cannot be used to specify that multiple files should be imported at a single import site.

Here's what I wanted or expected to see:

I would like ShellCheck to have a directive (e.g. source-glob= or perhaps source-list= for especially complex cases) that would allow the user to specify that multiple files should be imported at this site:

for lib in "$MAKEPKG_LIBRARY"/*.sh; do
	# shellcheck source-glob=libmakepkg/*.sh.in
	source "$lib"
done

A question might arise on how to handle such directives inside loops; perhaps the answer (if ShellCheck does not do this already) is to only process this directive exactly once per source site.

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