A && B || C vs if then else fi
Stéphane commented that
A && B || Ccannot be used in place of proper
if then else fi
Can someone explain what’s the difference?
It is very easy to make a mistake in cases like
A && B || C.
They are almost universally "write only" – once you wrote such compound statement and it works – it is difficult to change some parts of such statement without loosing the whole logic.
B commands are not a one-word commands – such compound statement can become extremely long and difficult to read, since you would need to horizontally scroll the line.
B – are commands with parameters, then you will have problems with finding
|| in the long lines of words. Again difficulties to understand and maintain.
If you have something like
make && run_test
That is fine. But that is actually an extent of usability. Anything more – better be rewritten to
if then fi