mardi 22 décembre 2015

Bash flow control issue

I have a bash flow control problem which I have resolved with 'while'. Here is a much simplified version:

while :; do 
[[ $x = $y ]] || { echo x & y differ; break; }; 
[[ $v -ge $u ]] || { echo v is less than u; break; }; 
echo another test and code; break;
done; 
echo end of tests

It consists of a series of unrelated tests followed by some code. The tests have to be done in order until one performs its code. These are the same rules as 'case' but I could not see how to use case for such unrelated tests. Please note that although I have used 'while' there is no loop involved.

Apart from a function what alternative succinct bash structure would others use in this situation?

Aucun commentaire:

Enregistrer un commentaire