What is wrong in the statement: $line || echo "error" && break;
I did a little script to execute commands:
Code:
#!/bin/bash what is the problem? if $line is work fine, it is not supposed to execute the right side of the OR gate. if $line is failed, it's supposed to continue the echo "error" and this is should to return true and only then execute the break. if I use: Code:
#!/bin/bash and also this code: Code:
#!/bin/bash |
Aren't both operators of equal precedence? If they are, it executes from left to right, evaluating the || first and if either one was true it does the &&, causing the break. In effect it acts like:
Code:
($line || echo "error") && break Code:
$line || ( echo "error" && break) |
All times are GMT -5. The time now is 11:07 PM. |