Skip to content

Reduce SC2016 false positives: concatenated quotes, command exceptions, BATS run flags#3

Draft
Copilot wants to merge 2 commits intodotysanfrom
copilot/fix-sc2016-false-positives
Draft

Reduce SC2016 false positives: concatenated quotes, command exceptions, BATS run flags#3
Copilot wants to merge 2 commits intodotysanfrom
copilot/fix-sc2016-false-positives

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

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:

# No longer warns — user demonstrably knows how quoting works
echo '$literal'"$expanded"
"${AWK[@]}" '{ print $1 }'"$inject"'more'

New command exceptions

  • dash — POSIX shell like sh/bash/ksh/zsh
  • gojq — Go implementation of jq
  • script — runs commands via -c
  • printf — 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 run with flags

run --separate-stderr bash -c '...' failed to resolve the effective command past flag arguments. Changed from firstArg (which bails on flags) to dropWhile isFlag args.

-- Before: fails when first arg is a flag
"run" -> firstArg
-- After: skips flags to find the actual command
"run" -> listToMaybe $ dropWhile isFlag args

Copilot AI and others added 2 commits April 20, 2026 18:52
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants