Of course it does. After replacing the variable, it reads [ !-z ], which is not a valid [ command. Use double quotes, or [[.
if [ ! -z "$errorstatus" ]
if [[ ! -z $errorstatus ]]
Of course it does. After replacing the variable, it reads [ !-z ], which is not a valid [ command. Use double quotes, or [[.
if [ ! -z "$errorstatus" ]
if [[ ! -z $errorstatus ]]