Script for auto replacement

master
Piotr Dziwinski 2012-06-20 17:11:10 +02:00
parent c0461add5f
commit faf4bf9788
1 changed files with 22 additions and 0 deletions

22
tools/sed-replace.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Script to automatically replace patterns in all source files
# Example usage
# (in main directory colobot):
# $ tools/sed-replace.sh src/app/d3dengine.cpp ...
# $ tools/sed-replace.sh `find . -name '*.cpp' -o -name '*.h'`
# List of sed commands (replacements)
replacements=( \
's/\bD3DVECTOR\b/Math::Vector/g' \
's/\bD3DMATRIX\b/Math::Matrix/g' \
)
# Loop over arguments
for file in "$@"; do
# Loop over replacements
for what in "${replacements[@]}"; do
sed -i "$what" "$file"
done
echo "$file"
done