Yes they (
[ -z "$VAR" ] and
[ "$VAR" = "" ] ...) are equivalent. Both are testing for emptiness of
$VAR (e.g. when it is not bound, or set to an empty string).
As commented by Celada, bad things might happen when using
[ "$VAR" = "" ] if
VAR is some valid test (e.g. if
-z), in particular when
test) is not a shell builtin. But on
[ is a builtin and that does not seem to be an issue. You could use
[ "x$VAR" = "x" ] for your test. See test(1)
Of course, I am assuming some POSIX shell or something similar.
-z might be slightly faster (but you should not care about microseconds in shell scripts) and you might find
= to perhaps be more readable.