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