You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if! [ -n"$JAVA_HOME" ];thenecho"JAVA_HOME not specified";fiif! [ -z"$STY" ];thenecho"You are already running screen";fi
Correct code:
if [ -z"$JAVA_HOME" ];thenecho"JAVA_HOME not specified";fiif [ -n"$STY" ];thenecho"You are already running screen";fi
Rationale:
You have negated test -z or test -n, resulting in a needless double-negative. You can just use the other operator instead:
# Identical tests to verify that a value is assigned! [ -z foo ] # Not has no value
[ -n foo ] # Has value# Identical tests to verify that a value is empty! [ -n foo ] # Not is non-empty
[ -z foo ] # Is empty
Exceptions:
This is a stylistic issue that does not affect correctness. If you prefer the original expression, you can Ignore it with a directive or flag.