if [str1 = str2] When two strings have the same content, the length is true
If [str1!= str2] True when string str1 and str2 are unequal
If [-N str1] is true when the length of the string is greater than 0 (string non-empty)
If [-Z str1] is true when the length of the string is 0 (empty string)
If [str1] is true when string str1 is Non-null
The shell uses-N to determine that the string is non-null.
Error usage:
args=$*
If [-N $ARGS]
Then
Print "with argument"
Fi
print "Without argument"
Regardless of the pass parameter, always enter the if inside.
Reason: Because the IF statement is equivalent to if [-N],shell will treat it as if [str1] without "", n is not null, so it is positive.
Correct usage: You need to add double quotes, or "$ARGS", to the $args.
args=$*
If [-N "$ARGS"]
Then
Print "with argument"
Fi
print "Without argument"
Copyright NOTICE: This article for the reprint article, originates from ciky2011, the copyright belongs to the original author all, welcome to share this article, reprint please reserve the source.