Skip to content

Commit 1092a11

Browse files
author
Wes Garland
committed
peter-jr - supply wc -L and realpath good-enough polyfills
1 parent 2db4d63 commit 1092a11

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 . >/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)