mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-10 15:22:58 -07:00
Add option to look for sources in alternate root paths
Add a new optional flag "-r|--root ROOTPATHS", where ROOTPATHS is a colon separated list of paths, that will look for external sources in alternate roots. This is particular useful when the run-time environment does not fully match the development environment. The #shellcheck source=file directive is useful, but has its limitations in certain scenarios. Also, in many cases the directive could be removed from scripts when the root flag is used. Script example.bash: #!/bin/bash source /etc/foo/config Example usage where etc/foo/config exists in skel/foo: # shellcheck -x -r skel/foo:skel/core example.bash
This commit is contained in:
parent
b824294961
commit
af46758ff1
3 changed files with 37 additions and 1 deletions
|
@ -2087,7 +2087,9 @@ readSource t@(T_Redirecting _ _ (T_SimpleCommand cmdId _ (cmd:file':rest'))) = d
|
|||
input <-
|
||||
if filename == "/dev/null" -- always allow /dev/null
|
||||
then return (Right "")
|
||||
else system $ siReadFile sys filename
|
||||
else do
|
||||
filename' <- system $ siFindSource sys filename
|
||||
system $ siReadFile sys filename'
|
||||
case input of
|
||||
Left err -> do
|
||||
parseNoteAtId (getId file) InfoC 1091 $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue