Running "break 2" command from parameter for function

Hello, people.

I have a "simple" script. In this script there is
Code:
loop (cycle?) > function1 > if[...] > function2 > loop2

function2 has a second loop inside it:

Code:
    function2 ()
    {
    while ... do
    ...
    done
    }

To end this sequence - function2 uses $param4 with break 2 command given in variable:

Code:
    while function1; do
    ...
    function2 "$param1" "$param2" "$param3" "$param4
    ...
    done

And:

Code:
    ...
    param4="break 2"
    ...

Is it a good idea to use such a scheme? Is there any possible risk or something else "negative"?
 
In general, the need to use less-than-simple loop breaking mechanisms means that the loops should be reorganized.

Is it a good idea to use such a scheme? Is there any possible risk or something else "negative"?

It is difficult to follow or debug. Possibly that's because the names of the functions and variables are not descriptive. Why not have the inner loop test the condition internally so it can exit by itself?
 
Back
Top