0% found this document useful (0 votes)
576 views

Can't Follow Non-Constant Source. Use A Directive To Specify Location

This document summarizes the SC1090 warning from ShellCheck, which occurs when ShellCheck cannot follow non-constant sources. It provides an example of problematic code that sources a file from a path determined at runtime. The correct code uses a # shellcheck directive to specify the source location. Specifying the source path allows ShellCheck to read the file and properly check for issues.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
576 views

Can't Follow Non-Constant Source. Use A Directive To Specify Location

This document summarizes the SC1090 warning from ShellCheck, which occurs when ShellCheck cannot follow non-constant sources. It provides an example of problematic code that sources a file from a path determined at runtime. The correct code uses a # shellcheck directive to specify the source location. Specifying the source path allows ShellCheck to read the file and properly check for issues.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

5/12/2020 SC1090 · koalaman/shellcheck Wiki

SC1090
Edit New Page Jump to bottom

Dale Wijnand edited this page on Oct 17, 2019 · 5 revisions

Can't follow non-constant source. Use a directive to


specify location.

Problematic code:

. "$(find_install_dir)/lib.sh"

Correct code:

# shellcheck source=src/lib.sh
. "$(find_install_dir)/lib.sh"

Rationale:
ShellCheck is not able to include sourced files from paths that are determined at runtime.
The file will not be read, potentially resulting in warnings about unassigned variables and
similar.

Use a Directive to point shellcheck to a fixed location it can read instead.

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.

https://github.com/koalaman/shellcheck/wiki/SC1090 1/2
5/12/2020 SC1090 · koalaman/shellcheck Wiki

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.

Add a custom footer

Pages 365

ShellCheck

Installation

CentOS6
More Installation Guides

Usage

Directive
Ignore

Integrating and extending

Azure Pipelines
CircleCI
DevGuide
Integration
JUnit
Phabricator
TravisCI
GitLab CI

Severity

Template

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature
above to find a specific one, or see Checks.

Clone this wiki locally

https://github.com/koalaman/shellcheck.wiki.git

https://github.com/koalaman/shellcheck/wiki/SC1090 2/2

You might also like