well... shell is good... enough for these kind of implementations... just needs quotes everywhere...

for flags, the following works perfectly:
 [ -z "${x} ]
 [ -n "${x} ]