#!/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"