summaryrefslogtreecommitdiffhomepage
path: root/bench/subst.sh
blob: 72c63d83305f5000d9c91814fca8798a032f7513 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
# shellcheck disable=SC3060  # the substitution is the feature under test
# ${v/pattern/replacement}, which is bash and ksh, not POSIX: dash and
# zash are reported as n/a.  The probe goes through eval so that the
# syntax error happens where the redirection can hide it.
( eval 'v=x; : ${v/x/y}' ) 2>/dev/null || exit 3
v=/usr/local/lib/zash/bin/zash
i=0
n=0
while [ $i -lt 40000 ]; do
    r=${v/usr/opt}
    n=$((n + ${#r}))
    i=$((i + 1))
done
echo "$n"