Updated SC1090 (markdown)

Vidar Holen
2020-06-28 17:31:12 -07:00
parent cc7758dcee
commit ed70dcfc04

@@ -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.