Conversation
The find/replace helper piped `grep -rl` output into `xargs gsed` using xargs' default whitespace splitting and quote processing, and passed the search pattern to grep/gsed without terminating option parsing. Paths containing spaces (or values beginning with `-`) could be split into multiple arguments or interpreted as options rather than data. Use NUL-delimited matching (`grep -rlZ | xargs -0`) so filenames are passed verbatim, and add `--` after grep's options to end option parsing. Behavior is otherwise unchanged.
|
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.



Description
.github/scripts/find_replace.shpipedgrep -rloutput intoxargs gsedusing xargs' default whitespace splitting and quote processing, and passed the
search pattern to grep/gsed without terminating option parsing. Paths
containing spaces, quotes, or values beginning with
-could be split intomultiple arguments or interpreted as options rather than data.
This change uses NUL-delimited matching (
grep -rlZ | xargs -0) so filenamesare passed verbatim, and adds
--after grep's options to end option parsing.Behavior is otherwise unchanged. This is a CI helper-script hardening / hygiene
improvement.
Test Steps
In a scratch directory with two files containing the search text — one whose
name contains a space — ran
find_replace.sh FOO BAR:FOOreplaced withBARxargssplit it into non-existent paths)bash -nreports no syntax errors.Checklist:
Related Issue
N/A
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.