mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-10-09 23:53:04 -04:00
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.
6 lines
194 B
Bash
Executable file
6 lines
194 B
Bash
Executable file
#!/bin/bash
|
|
old_text=$1
|
|
new_text=$2
|
|
echo "Old text: ${old_text}"
|
|
echo "New text: ${new_text}"
|
|
grep -rlZ -- "${old_text}" . | xargs -0 gsed -i -e '1h;2,$H;$!d;g' -e "s/${old_text}/${new_text}/g"
|