Skip to content

Commit 47cac66

Browse files
committed
melting-pot: fix macOS bug in record-success func
BSD grep's bug, really. Let's work around it!
1 parent 15b8857 commit 47cac66

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

melting-pot.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,22 @@ cat <<\RECORD > record-success.sh
675675
#!/bin/sh
676676
test "$1" || { echo "[ERROR] Please specify project to update."; exit 1; }
677677
678+
containsLine() {
679+
pattern=$1
680+
file=$2
681+
test -f "$file" || return
682+
# HACK: The obvious way to do this is:
683+
#
684+
# grep -qxF "$pattern" "$file"
685+
#
686+
# Unfortunately, BSD grep dies with "out of memory" when the pattern is 5111
687+
# characters or longer. So let's do something needlessly complex instead!
688+
cat "$file" | while read line
689+
do
690+
test "$pattern" = "$line" && echo 1 && break
691+
done
692+
}
693+
678694
dir=$(cd "$(dirname "$0")" && pwd)
679695
buildLog="$dir/$1/build.log"
680696
test -f "$buildLog" || exit 1
@@ -685,11 +701,12 @@ mkdir -p "$(dirname "$successLog")"
685701
deps=$(grep "^\[INFO\] " "$buildLog" |
686702
sed -e "s/^.\{10\}//" -e "s/ -- .*//" |
687703
sort | tr '\n' ',')
688-
test -f "$successLog" && grep -Fxq "$deps" "$successLog" || {
704+
if [ -z "$(containsLine "$deps" "$successLog")" ]
705+
then
689706
echo "$deps" > "$successLog".new
690707
test -f "$successLog" && cat "$successLog" >> "$successLog".new
691708
mv -f "$successLog".new "$successLog"
692-
}
709+
fi
693710
RECORD
694711
chmod +x record-success.sh
695712
}

0 commit comments

Comments
 (0)