Suppose you want your script to take variables from environment:
#!/usr/bin/env bash
set -eu
if (( ${A-} )); then
echo true
else
echo false
fi
Arithmetic expansion seems to be more reasonable here to handle (empty), 0, 1 cases, or else:
if [ "${A-}" ] && [ "${A-}" != 0 ]; then
But then,
$ A='1 - 1' ./1.sh
false
$ A='B = 1' ./1.sh
true
So now you can basically change variables, which you generally don't want to allow. What would you suggest? How to process boolean flags taken from environment variables?
A='A = 1 - 1' ./sh? It doesn't work with the version that uses[ ].