Shell advanced syntax?

Hehe :smiley:
@ctsgnb: We all seem to agree. Could we have your final seal of approval? :wink:

Then, I agree with all of you Dudes, i long for the next picnic of nitpicks ! :smiley:

BTW, I think the exit statement in the script more then proves scottn's point. Let's change it to exit 1

Yes, you are right! I think it was also unclear, but after the examples given latter by Alister its became more or less transparent.
And thank you additionaly for reading my mind! :slight_smile:

---------- Post updated at 06:02 AM ---------- Previous update was at 05:27 AM ----------

Stop!!....I just thinking one more time about this construct:

if compiler_path_exist && export ==0 || {"echo Blaaa.blaaa"; exit} 

and wondering what does OR (||) mean here...
Will the "OTHERWISE" be the right logical explanation? Or do we expect now the echo command to return something ? :))

Thanx again!

Hi, this is discussed extensively in this thread. bottom line: The right part of || is triggered if the path does not exist. However, this all can be quite confusing, I would advise to use the construction in post #4

When writing logic, I shy away from mixed "and/or", never remembering, or liking reliance on, precedence, so I would have used some sort of parentheses to tie the first two together and indented them as not peers of the OR operand (the parentheses are the OR peer). Easy to read is esay to get right the first time, debug, read, maintain and extend. You, too, deserve readable code! The career you save/enhance might be your own.

When writing procedure, the gay spiderweb of tree logic and one return/exit at the very end or piling 5 steps in one line is not productive. If you can return or exit from anywhere, why would you not use the power of that?

It is always nicer to use a series of simple if statements of the form: if this step fails then report the error, undo any damage you have not dealt with by good design that gracefully anticipates the possibility of this failure (rollback transaction, for instance), and exit or return from this list of steps. The one step check error form keeps all aspects of one step together and away from unrelated steps, and encourages good error checking and reporting, so it is easy to develop (quick debug), read, maintain and extend. You, too, deserve readable code! The career you save/enhance might be your own.