huangwason
Programmer
To check a file, if it does not exit, assign a value to exit code and print out something, I use the following code:
[ -f $FILE ] || EXIT_CODE=1 && echo "$FILE does not exist"
assure $FILE does not exist, the above logical operator can be regarded as:
(False || TRUE) && TRUE
EXIT_CODE is assigned to 1, it is ok.
but for &&, as long as the return exit code of || is 0, it print out, the result is it always print out, which is not my intension.
is there a solution to make the above logical operation doing like this
False || (TRUE && TRUE)
thanks
[ -f $FILE ] || EXIT_CODE=1 && echo "$FILE does not exist"
assure $FILE does not exist, the above logical operator can be regarded as:
(False || TRUE) && TRUE
EXIT_CODE is assigned to 1, it is ok.
but for &&, as long as the return exit code of || is 0, it print out, the result is it always print out, which is not my intension.
is there a solution to make the above logical operation doing like this
False || (TRUE && TRUE)
thanks