The [[...]] is processed as part of the shell grammar whereas [...] is processed like any other command.
Operators and operands are detected when the command is read, not after expansions are performed.
Operators and operands are detected when the command is read, not after expansions are performed.
- The shell does not do word splitting or path-name generation inside [[...]].This allows patterns to be specified for
string matching purposes.
- Parameter expansion and command substitution is allowed.
- Prevents many logic errors in scripts. e.g [ "$x" = "TEST" ] can be written as [[ $x = "TEST" ]] the variables don't need to be quoted.
- The &&, ||, <, and > operators work within a [[ ]] test, despite giving an error within a [ ] construct.
No comments:
Post a Comment