Skip to content

fix: replace xargs trim with sed to handle quotes in descriptions#2351

Merged
mnriem merged 1 commit intogithub:mainfrom
mnriem:fix/2339-xargs-quote-safe-trim
Apr 24, 2026
Merged

fix: replace xargs trim with sed to handle quotes in descriptions#2351
mnriem merged 1 commit intogithub:mainfrom
mnriem:fix/2339-xargs-quote-safe-trim

Conversation

@mnriem
Copy link
Copy Markdown
Collaborator

@mnriem mnriem commented Apr 24, 2026

Summary

create-new-feature.sh uses xargs to strip surrounding whitespace from the FEATURE_DESCRIPTION argument. Because xargs re-parses its stdin as shell-like tokens, any input containing a single quote ('), double quote ("), or backslash (\) aborts with xargs: unterminated quote.

Natural-language descriptions frequently include apostrophes (user's, can't, etc.), so this is easy to trigger in normal usage.

Changes

Replace the xargs call with a sed-based trim in both locations:

  • scripts/bash/create-new-feature.sh (line 87)
  • extensions/git/scripts/bash/create-new-feature.sh (line 98)
# Before
FEATURE_DESCRIPTION=$(echo "$FEATURE_DESCRIPTION" | xargs)

# After
FEATURE_DESCRIPTION=$(echo "$FEATURE_DESCRIPTION" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g')

The PowerShell equivalents already use .Trim() and are not affected.

Tests

Added TestDescriptionQuoting class to tests/test_timestamp_branches.py with 10 tests:

  • 8 positive tests — apostrophes, double quotes, backslashes, and mixed special characters succeed in both core and extension scripts
  • 1 negative test — whitespace-only descriptions are still rejected
  • 1 regression guard — plain descriptions continue to work

Full suite: 1677 passed.

Fixes #2339

xargs re-parses stdin as shell tokens, causing 'unterminated quote'
errors when feature descriptions contain apostrophes, double quotes,
or backslashes. Replace with sed-based whitespace trim that preserves
input verbatim.

Add regression tests for special characters in descriptions (core and
extension scripts), plus a negative test for whitespace-only input.

Fixes github#2339
Copilot AI review requested due to automatic review settings April 24, 2026 12:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a quoting bug in the create-new-feature.sh whitespace-trimming step by replacing xargs (which re-parses input and fails on quotes/backslashes) with a sed-based trim, and adds regression tests to ensure descriptions containing special characters work in both core and extension scripts.

Changes:

  • Replace FEATURE_DESCRIPTION trimming from xargs to a quote-safe sed expression in both bash scripts.
  • Add pytest coverage for apostrophes, double quotes, and backslashes (core + extension), plus whitespace-only rejection and a plain-description guard.
Show a summary per file
File Description
scripts/bash/create-new-feature.sh Switches whitespace trimming to sed to avoid xargs quote/backslash parsing failures.
extensions/git/scripts/bash/create-new-feature.sh Applies the same trim fix to the git extension’s create-new-feature.sh.
tests/test_timestamp_branches.py Adds regression tests for issue #2339 covering special characters and whitespace-only descriptions.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@mnriem mnriem merged commit 13d88d2 into github:main Apr 24, 2026
15 checks passed
@mnriem mnriem deleted the fix/2339-xargs-quote-safe-trim branch April 24, 2026 12:13
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.

create-new-feature.sh: xargs-based trimming breaks descriptions containing apostrophes or quotes

2 participants