mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC1090 (markdown)
18
SC1090.md
18
SC1090.md
@@ -3,14 +3,14 @@
|
||||
### Problematic code:
|
||||
|
||||
```sh
|
||||
. "$(find_install_dir)/lib.sh"
|
||||
. "${util_path}"
|
||||
```
|
||||
|
||||
### Correct code:
|
||||
|
||||
```sh
|
||||
# shellcheck source=src/lib.sh
|
||||
. "$(find_install_dir)/lib.sh"
|
||||
# shellcheck source=src/util.sh
|
||||
. "${util_path}"
|
||||
```
|
||||
|
||||
### Rationale:
|
||||
@@ -19,14 +19,8 @@ ShellCheck is not able to include sourced files from paths that are determined a
|
||||
|
||||
Use a [[Directive]] to point shellcheck to a fixed location it can read instead.
|
||||
|
||||
ShellCheck v0.7.2+ will strip a single expansion followed by a slash, e.g. `${var}/util.sh` or `$(dirname "${BASH_SOURCE[0]}")/util.sh`, and treat them as `./util.sh`. This allowing the use of `source-path` directives or `-P` flags to specify the a location.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
If you don't care that ShellCheck is unable to account for the file, specify `# shellcheck source=/dev/null`.
|
||||
|
||||
#### shellcheck -P *SOURCEPATH*, --source-path=*SOURCEPATH*
|
||||
|
||||
`shellcheck -P dir1:dir2/libs`
|
||||
|
||||
Specify paths to search for sourced files, separated by `:` on Unix and `;` on Windows. Absolute paths will also be rooted in these.
|
||||
|
||||
The special path ***`SCRIPTDIR`*** can be used to specify searching the currently checked script's directory, as in **`-P SCRIPTDIR`** or **`-P SCRIPTDIR/../libs`**. Subsequent `-P` flags accumulate and take precedence.
|
||||
If you don't care that ShellCheck is unable to account for the file, specify `# shellcheck source=/dev/null`.
|
Reference in New Issue
Block a user