Re:Stronger Shell
by vodik on Wednesday August 12, 2015 @01:29PM
(#10049220)
The core difference is that:
- `[` is treated as a statement
- `[[` is treated as an expression
Which, for example, is why you can't use `>` in `[` based expressions. Bash thinks you want to redirect the output of `[` to somewhere else. This restriction is lifted for `[[` and makes for much more natural looking code.
- `[` is treated as a statement
- `[[` is treated as an expression
Which, for example, is why you can't use `>` in `[` based expressions. Bash thinks you want to redirect the output of `[` to somewhere else. This restriction is lifted for `[[` and makes for much more natural looking code.