From 5e1189fc82c825b81bee077e82eea77db3d8347a Mon Sep 17 00:00:00 2001 From: Stavros Ntentos <133706+stdedos@users.noreply.github.com> Date: Tue, 7 Sep 2021 14:01:01 +0300 Subject: [PATCH] Document `source-path` / `source-path=SCRIPTDIR` --- Directive.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Directive.md b/Directive.md index 7f2150c..2e20e86 100644 --- a/Directive.md +++ b/Directive.md @@ -57,6 +57,33 @@ Tell ShellCheck where to find a sourced file (since 0.4.0): . "$(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 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)):