From ed70dcfc043750bb24ad5234c98b03980116c37c Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 28 Jun 2020 17:31:12 -0700 Subject: [PATCH] Updated SC1090 (markdown) --- SC1090.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/SC1090.md b/SC1090.md index d3f826f..f7f361e 100644 --- a/SC1090.md +++ b/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. \ No newline at end of file +If you don't care that ShellCheck is unable to account for the file, specify `# shellcheck source=/dev/null`. \ No newline at end of file