mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Document source-path
/ source-path=SCRIPTDIR
27
Directive.md
27
Directive.md
@@ -57,6 +57,33 @@ Tell ShellCheck where to find a sourced file (since 0.4.0):
|
|||||||
. "$(locate_config)"
|
. "$(locate_config)"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### source-path
|
||||||
|
Give ShellCheck a path on where to search sourced file (since 0.x.x):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# shellcheck source-path=src/examples
|
||||||
|
. "$(locate_config)"
|
||||||
|
```
|
||||||
|
(similar to the example above)
|
||||||
|
|
||||||
|
Additionally, with `source-path=SCRIPTPATH` you can do things like:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
#!/bin/sh
|
||||||
|
# file: scripts/test.sh
|
||||||
|
|
||||||
|
# shellcheck source-path=SCRIPTPATH
|
||||||
|
. "$(dirname "$(realpath "$0")")/utils.sh"
|
||||||
|
```
|
||||||
|
|
||||||
|
for file layout:
|
||||||
|
```
|
||||||
|
.
|
||||||
|
└── scripts
|
||||||
|
├── test.sh
|
||||||
|
└── utils.sh
|
||||||
|
```
|
||||||
|
|
||||||
### shell
|
### shell
|
||||||
Specify the shell for a script (similar to the shebang, if you for any reason don't want to add one) (since [0.4.5](https://github.com/koalaman/shellcheck/issues/581#issuecomment-249437837)):
|
Specify the shell for a script (similar to the shebang, if you for any reason don't want to add one) (since [0.4.5](https://github.com/koalaman/shellcheck/issues/581#issuecomment-249437837)):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user