Overwrite internal field separator when replacing.
Problem: Currently the `for` in bash will break up lists by whitespace, so if a filename has a space in it the `for` will break it up incorrectly. AG will separate the files with a newline character, so this temporarily overwrites the `IFS` to be used correctly for this use case. [Docs](https://bash.cyberciti.biz/guide/$IFS)
This commit is contained in:
parent
f25b410bba
commit
1dc550d985
1 changed files with 1 additions and 0 deletions
|
@ -11,6 +11,7 @@ shift
|
|||
|
||||
items=$(ag -l --nocolor "$find_this" "$@")
|
||||
temp="${TMPDIR:-/tmp}/replace_temp_file.$$"
|
||||
IFS=$'\n'
|
||||
for item in $items; do
|
||||
sed "s/$find_this/$replace_with/g" "$item" > "$temp" && mv "$temp" "$item"
|
||||
done
|
||||
|
|
Loading…
Add table
Reference in a new issue