summaryrefslogtreecommitdiffhomepage
path: root/bench/dbracket.sh
blob: 24a44d712d4018722ccfe07741ce6f8724886954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
# [[ ]] in a loop (the same work as with [ ], see testloop.sh).
# Shells without [[ ]] (dash) are reported as n/a.
# shellcheck disable=SC2078  # the constant is the point: does [[ ]] exist?
# An `if` with no `else` answers 0 even when the condition failed, so
# the probe has to say what it means.
( if [[ a ]]; then :; else exit 3; fi ) 2>/dev/null || exit 3
i=0
n=0
while [[ $i -lt 100000 ]]; do
    if [[ $i != 7 && -n $i ]]; then n=$((n + 1)); fi
    i=$((i + 1))
done
echo $n