From 7b1d653191fda02de63b9cee4447c5c3fdabbde9 Mon Sep 17 00:00:00 2001 From: Bart Thomee <11445373+bthomee@users.noreply.github.com> Date: Sun, 2 Nov 2025 18:26:21 +0000 Subject: [PATCH] Use pushd and popd --- .github/scripts/rename/copyright.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/scripts/rename/copyright.sh b/.github/scripts/rename/copyright.sh index 393d0cac33..12b1848f09 100755 --- a/.github/scripts/rename/copyright.sh +++ b/.github/scripts/rename/copyright.sh @@ -25,6 +25,14 @@ if [ "$#" -ne 1 ]; then exit 1 fi +DIRECTORY=$1 +echo "Processing directory: ${DIRECTORY}" +if [ ! -d "${DIRECTORY}" ]; then + echo "Error: Directory '${DIRECTORY}' does not exist." + exit 1 +fi +pushd ${DIRECTORY} + # Prevent sed and echo from removing newlines and tabs in string literals by # temporarily replacing them with placeholders. This only affects one file. PLACEHOLDER_NEWLINE="__NEWLINE__" @@ -35,12 +43,7 @@ ${SED_COMMAND} -i -E "s@\\\t@${PLACEHOLDER_TAB}@g" src/test/rpc/ValidatorInfo_te # Process the include/ and src/ directories. DIRECTORIES=("include" "src") for DIRECTORY in "${DIRECTORIES[@]}"; do - DIRECTORY=$1/${DIRECTORY} echo "Processing directory: ${DIRECTORY}" - if [ ! -d "${DIRECTORY}" ]; then - echo "Error: Directory '${DIRECTORY}' does not exist." - exit 1 - fi find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" -o -name "*.macro" \) | while read -r FILE; do echo "Processing file: ${FILE}" @@ -99,4 +102,5 @@ fi ${SED_COMMAND} -i -E "s@${PLACEHOLDER_NEWLINE}@\\\n@g" src/test/rpc/ValidatorInfo_test.cpp ${SED_COMMAND} -i -E "s@${PLACEHOLDER_TAB}@\\\t@g" src/test/rpc/ValidatorInfo_test.cpp +popd echo "Removal complete."