static_parse_limit (printf_format): printf with a quoted $(printf '%s' "$1" | sed …) argument marks shell scripts partially inspected
Summary
A POSIX shell printf whose argument is a double-quoted command substitution that pipes printf '%s' "$1" into another command makes static_patterns_tool_misuse record static_parse_limit (parser_diagnostic.check = printf_format, cause = unsupported_syntax, unchecked_scope = command_word), so the file counts as partially inspected and the scan is partial.
This is the common "quote a value for sh/cron" idiom, for example:
cronq() { printf "'%s'" "$(printf '%s' "$1" | sed -e "s/'/'\\\\''/g" -e 's/%/\\%/g')"; }
The outer printf is the command word and its arguments are data; the inner substitution's output comes from sed, not from printf.
Reproducer
SKILL.md:
---
name: sh-escape
description: Print a crontab line for a path. Use when the user asks for a cron entry.
---
# Shell escape
Run `scripts/cron.sh <path>`.
scripts/cron.sh (one line after the shebang), then skillspector scan <dir> --no-llm --format json:
Line in scripts/cron.sh |
Result |
|---|---|
printf "'%s'" "$(printf '%s' "$1" | sed 's/a/b/')" |
partial, printf_format / unsupported_syntax |
printf '%s\n' "$(printf '%s' "$1" | sed 's/a/b/')" |
partial, same |
printf "'%s'" "$(echo "$1" | sed 's/a/b/')" |
complete |
x="$(printf '%s' "$1" | sed 's/a/b/')" |
complete |
printf "'%s'" "$1" |
complete |
So it needs both an outer printf and an inner printf at the start of a quoted substitution that is not a literal printf (here, a pipeline). From a read of the code, the quoted-result branch of _static_printf_substitution fails (failed() with the default printf_format / unsupported_syntax) whenever a quoted substitution starts with printf and _has_literal_printf_arguments is false, even when the substitution is a pipeline whose output another command produces.
Expected: the inner substitution is treated as runtime-dependent data in an argument position of the outer printf (as it is for the echo and assignment variants), and the file completes static analysis.
Real-world occurrences
Versions
main at 17c4d386 (uv sync; skillspector --version prints v2.12.0 from pyproject.toml), where the diagnostic fields above come from. The 2.13.3 release wheel reports the same static_parse_limit row for scripts/cron.sh (without parser_diagnostic). macOS, Python 3.12, --no-llm.
Related but different triggers: #694 (a literal $(printf '\177ELF\001')), #628 and #901 (closed).
Hi, I would like to pick this up. I have reproduced it locally: the quoted printf substitution case scores 25 with a static_parse_limit row while the echo and assignment variants complete. The quoted-result branch of _static_printf_substitution fails whenever a quoted substitution starts with printf and _has_literal_printf_arguments is false, even for a pipeline whose output another command produces. I will open a PR with a fix and regression tests.