Skip to content

Commit 987f8f0

Browse files
committed
In format.sh, replace sed with perl.
1 parent 3f4cf8d commit 987f8f0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

format.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ if ! (yapf --version &>/dev/null && ruff --version &>/dev/null); then
1919
pip install -r requirements-lint.txt
2020
fi
2121

22-
SED_CMD="sed -i"
23-
if [[ "$OSTYPE" == "darwin"* ]]; then
24-
SED_CMD="sed -i ''"
25-
fi
26-
2722
YAPF_VERSION=$(yapf --version | awk '{print $2}')
2823
RUFF_VERSION=$(ruff --version | awk '{print $2}')
2924

@@ -142,14 +137,14 @@ if command -v clang-format &>/dev/null; then
142137
# Replace "#pragma unroll" by "// #pragma unroll"
143138
find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' -o -name '*.cu' -o -name '*.cuh' \) \
144139
-not -path "./build/*" \
145-
-exec $SED_CMD 's/#pragma unroll/\/\/#pragma unroll/g' {} +
140+
-exec perl -pi -e 's/#pragma unroll/\/\/#pragma unroll/g' {} +
146141
find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' -o -name '*.cu' -o -name '*.cuh' \) \
147142
-not -path "./build/*" \
148143
-exec clang-format -i {} +
149144
# Replace "// #pragma unroll" by "#pragma unroll"
150145
find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' -o -name '*.cu' -o -name '*.cuh' \) \
151146
-not -path "./build/*" \
152-
-exec $SED_CMD 's/\/\/ *#pragma unroll/#pragma unroll/g' {} +
147+
-exec perl -pi -e 's/\/\/ *#pragma unroll/#pragma unroll/g' {} +
153148
}
154149

155150
# Format changed C/C++ files relative to main
@@ -163,9 +158,9 @@ if command -v clang-format &>/dev/null; then
163158
MERGEBASE="$(git merge-base $BASE_BRANCH HEAD)"
164159

165160
if ! git diff --diff-filter=ACM --quiet --exit-code "$MERGEBASE" -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.cu' '*.cuh' &>/dev/null; then
166-
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.cu' '*.cuh' | xargs $SED_CMD 's/#pragma unroll/\/\/#pragma unroll/g'
161+
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.cu' '*.cuh' | xargs perl -pi -e 's/#pragma unroll/\/\/#pragma unroll/g'
167162
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.cu' '*.cuh' | xargs clang-format -i
168-
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.cu' '*.cuh' | xargs $SED_CMD 's/\/\/ *#pragma unroll/#pragma unroll/g'
163+
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.cu' '*.cuh' | xargs perl -pi -e 's/\/\/ *#pragma unroll/#pragma unroll/g'
169164
fi
170165
}
171166

0 commit comments

Comments
 (0)