Skip to content

Commit 8a352b9

Browse files
authored
Merge pull request #99 from Distributive-Network/wes/peter-jr-mac-compat
peter-jr - supply wc -L and realpath good-enough polyfills
2 parents 237a56a + 1cd217d commit 8a352b9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

peter-jr

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ grey()
9797
printf "\e[0;90m%s\e[0m" "$*"
9898
}
9999

100+
if ! realpath --relative-to=. . >/dev/null 2>&1; then
101+
realpath()
102+
{
103+
local remove
104+
if [[ "$1" == --relative-to=* ]]; then
105+
remove="${1:14}/"
106+
shift 1
107+
else
108+
remove="$"
109+
fi
110+
local filename="$1"
111+
local dirname=`dirname "$1"`
112+
local basename=`basename "$1"`
113+
(
114+
[ "$dirname" ] || dirname="."
115+
cd "$dirname" && echo "`pwd -P`/$basename"
116+
) | sed -e "s;${remove};;g"
117+
}
118+
fi
119+
100120
findTests()
101121
{
102122
for loc in "${testLocations[@]}"
@@ -111,7 +131,11 @@ findTests()
111131
done
112132
}
113133

114-
longestFilenameLen=`findTests | wc -L`
134+
if wc -L </dev/null >/dev/null 2>&1; then
135+
longestFilenameLen=`findTests | wc -L`
136+
else
137+
longestFilenameLen=`findTests | awk '{print length}' | sort -rn | head -1`
138+
fi
115139

116140
findTests \
117141
| (shuf 2>/dev/null || cat) \

0 commit comments

Comments
 (0)