Reduce SC2016 false positives: concatenated quotes, command exceptions, BATS run flags#3
Draft
Reduce SC2016 false positives: concatenated quotes, command exceptions, BATS run flags#3
Conversation
…concatenated quotes detection, and fix BATS run with flags - Add gojq, dash, script, printf to command exception list - Add PS0 to commonly-quoted variable names - Suppress SC2016 when single-quoted string is concatenated with double-quoted expansions - Fix run (BATS) to skip flags when resolving effective command - Add test properties for all new behaviors Agent-Logs-Url: https://github.com/dotysan/shellcheck/sessions/90f001fb-db77-4304-9af4-a819f4d48f85 Co-authored-by: dotysan <5060170+dotysan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotysan/shellcheck/sessions/90f001fb-db77-4304-9af4-a819f4d48f85 Co-authored-by: dotysan <5060170+dotysan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
dotysan
April 21, 2026 01:15
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SC2016 fires on single-quoted strings containing
$-like patterns, but has a high false-positive rate across several common patterns reported in multiple open issues.Concatenated quotes detection
When a single-quoted string is part of a word concatenated with double-quoted expansions, the user clearly understands quoting. Suppress SC2016 in this case:
New command exceptions
dash— POSIX shell like sh/bash/ksh/zshgojq— Go implementation of jqscript— runs commands via-cprintf— format strings intentionally contain literal$PS0 added to commonly-quoted variables
PS0(bash 4.4+) joins PS1–PS4 and PROMPT_COMMAND as variables where single-quoted$references are intentional.BATS
runwith flagsrun --separate-stderr bash -c '...'failed to resolve the effective command past flag arguments. Changed fromfirstArg(which bails on flags) todropWhile isFlag args.