mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC1090 (markdown)
14
SC1090.md
14
SC1090.md
@@ -1,20 +1,20 @@
|
||||
## This source will be skipped since it's not constant.
|
||||
## Can't follow non-constant source. Use a directive to specify location.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
source "$1/lib.sh"
|
||||
. "$(find_install_dir)/lib.sh"
|
||||
|
||||
### Correct code:
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$1/lib.sh"
|
||||
# shellcheck source=src/lib.sh
|
||||
. "$(find_install_dir)/lib.sh"
|
||||
|
||||
### Rationale:
|
||||
|
||||
ShellCheck is not able to include sourced files from non-constant paths.
|
||||
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.
|
||||
|
||||
Instead, be aware that anything in the sourced file will be ignored, and then disable the message.
|
||||
Use a [[Directive]] to point shellcheck to a fixed location it can read instead.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
Ignore the message with a [[directive]].
|
||||
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