Skip to content

Commit

Permalink
use perl instead of sed in style checks for portability to MacOS (AMR…
Browse files Browse the repository at this point in the history
…eX-Codes#4127)

## Summary

`sed -i` does not function the same for GNU and BSD sed and a simple
portable command between the two is apparently not possible. Therefore,
the style check scripts do not work by default when running on Macs,
unless the user installs `gsed` and aliases `sed` to run that instead.
For portability,`perl` can be used instead of `sed`.

## Additional background

Proposed solution taken from here:
https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux
  • Loading branch information
baperry2 authored Sep 4, 2024
1 parent 65d10a1 commit 61b91f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/style/check_tabs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find . -type d \( -name .git \
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/\t/\ \ \ \ /g' {} +
-exec perl -i -pe's/\t/\ \ \ \ /g' {} +

gitdiff=`git diff`

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style/check_trailing_whitespaces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find . -type d \( -name .git \
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \) \
\) \
-exec grep -Iq . {} \; \
-exec sed -i 's/[[:blank:]]\+$//g' {} +
-exec perl -i -pe's/[[:blank:]]+$//g' {} +

gitdiff=`git diff`

Expand Down

0 comments on commit 61b91f9

Please sign in to comment.