embedded shell script mental off-by-one error