Not sure about your shell, but...
The form "[ ]" is essentially calling the external "test" command, and thus everything is evaluated by the shell first. That's why you get "
test: argument expected" when
$objid is NULL, since the expression evaluates to "[ -z ]".
When using "[ ]", you really need to quote all values/variables. But, you can use the super-secret
double bracket:
if [[ -z $myvar ]]; then.....
WIth the double-brackets, the test is a shell builtin. So nothing needs to be quoted, since it is not evaluated prior to being tested. Plus, you will save dozens of milliseconds by avoiding an external program.