feat: support leading dynamic section when sourcing
This does the same thing that ShellCheck does (here).
To support the common pattern of . "$CONFIGDIR/mylib.sh", ShellCheck strips one leading, dynamic section before trying to locate the rest.
fixes #926, fixes #659
this can now handle all the below cases:
. "$dir/file"
. "$dir/other/file"
. "$dir"/file
. $dir/file
. $dir"/file"
. "$dir"/"file"
. "${dir:-.}"/"file"
. ${dir}/"fi"l'e'
source "$dir/file"
It intentionally fails on these:
. "$dir/$file"
. "$dir/other/$file"
. "$(cmd)/file"
. $(cmd)/file
It intentionally fails on these:
is there a way to make it work? seems that's the much more usage case.
It intentionally fails on these:
is there a way to make it work? seems that's the much more usage case.
potentially, but these cases are process substitution and dynamic file sourcing. if you really want to use process substitution, assign it to a variable, then use that - this way it will work with shellcheck too. as to dynamic file sourcing, at the point this is evaluated, there's no way to get the "static" value of a variable, so there's no meaningful way to support that.
the current implementation matches shellcheck's behavior
there's no way
:thinking: ok, anyway, this looks was an good improvement.
This would be great! All of our sources are of the form . "$ScriptDir/something.sh" or . "$ScriptDir/dir/something.sh".