utils/namesub: operate on original file unless running in debug mode

This commit is contained in:
jj
2025-04-10 20:03:29 +00:00
parent f0c08bbdf3
commit cd9c5d61e3

View File

@@ -57,11 +57,15 @@ do_sub() {
continue;
fi
cp "$file_path" "$file_path.new"
perl -pi -e "$REGEX_CHAIN" "$file_path.new"
if [ "$DEBUG" = 1 ]; then
cp "$file_path" "$file_path.new"
perl -pi -e "$REGEX_CHAIN" "$file_path.new"
diff -Naur "$file_path" "$file_path.new" || true
mv "$file_path.new" "$file_path"
else
perl -pi -e "$REGEX_CHAIN" "$file_path"
fi
diff -Naur "$file_path" "$file_path.new" || true
mv "$file_path.new" "$file_path"
done <<< "$FILE_LIST"
}