Skip to content

Commit 180c155

Browse files
Weyzumilesfrain
andauthored
[Scripts] Make removeAnchors script support Darwin's BSD find (#444)
* [Scripts] Make removeAnchors script support Darwin's BSD find --------- Co-authored-by: Miles Frain <[email protected]>
1 parent a04df70 commit 180c155

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/removeAnchors.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ set -x
88
set -e
99

1010
# All .purs & .js files in the src/ and test/ directories of chapter exercises.
11-
FILES=$(find . -regextype posix-extended -regex '\./exercises/chapter[0-9]{1,2}/(src|test)/.*\.(purs|js)' -type f)
11+
FIND_FILES_PATTERN='\./exercises/chapter[0-9]{1,2}/(src|test)/.*\.(purs|js)'
12+
13+
EXTENDED_REGEX_FLAGS="-regextype posix-extended"
14+
# BSD find has different flags for extended regex
15+
if [[ $(uname) == 'FreeBSD' || $(uname) == 'Darwin' ]]; then
16+
EXTENDED_REGEX_FLAGS='-E'
17+
fi
18+
FILES=$(find . -type f $EXTENDED_REGEX_FLAGS -regex $FIND_FILES_PATTERN)
1219

1320
for f in $FILES; do
1421
# Delete lines starting with an 'ANCHOR' comment

0 commit comments

Comments
 (0)