From cd9c5d61e3cd2c439b13e3246fa9a74fd995ae05 Mon Sep 17 00:00:00 2001 From: jj Date: Thu, 10 Apr 2025 20:03:29 +0000 Subject: [PATCH] utils/namesub: operate on original file unless running in debug mode --- utils/name_substitution.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utils/name_substitution.sh b/utils/name_substitution.sh index b367a92a..a5e2105e 100755 --- a/utils/name_substitution.sh +++ b/utils/name_substitution.sh @@ -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" }