3 ms·
> Note that [[ is actually a command/program that returns either 0 (true) or 1 (false). This is true for the [ command, which is the same as `test`, but the [[
by ben509 8y ago
> Note that [[ is actually a command/program that returns either 0 (true) or 1 (false).
This is true for the [ command, which is the same as `test`, but the [[ ]] syntax is parsed directly by bash, as is (( )). In particular, [[ ]] is not subject to whitespace splitting, so you don't need to quote most variables.
They mention $(( )), but don't go into (( )), which gives you very nice integer arithmetic and logic:
for (( x = 0; x < 5; x += 2 )); do
echo $x
(( y = x * 10, z = y + 2 ))
echo $y $z
done
- chubot 8y agoYes I wrote about this on my blog: [ Is a Builtin, But [[ Is Part of the Language http://www.oilshell.org/blog/2016/10/12.html http://www.oilshell.org/blog/2016/10/12.html I didn't know that before I started implementing a shell :) I knew that [ could be a builtin or /usr/bin/[, but not about the difference between [ and [[.