Long long time ago, back in SunOS ages and shell Bourne, I saw this code
if [ $x ]; then ...
The author told me, I was a junior java developer, it checks if x exists.
I didn’t like the code. I just found out that “1 = 2” does not exist…
$ x='1 = 2'; if [ $x ]; then echo ok; else echo notok; fi notok $ x='foo'; if [ $x ]; then echo ok; else echo notok; fi ok
This is also documented in some less-ancient manpages
test "$1" test ! "$1" could not be used reliably on some historical systems. Unexpected results would occur if such a string condition were used and $1 expanded to !, (, or a known unary primary. Better constructs are, respectively, test -n "$1" test -z "$1"
Never trust your senior administrator, just test test test …
And even if you test but the code is not robust, don’t do it, it may break one day