forward/backward capable prompt

Hi,

I would like to construct an interactive prompt for a series of bash shell scripts. This prompt will ask the user a series of questions, and the answers will determine which scripts are run, and in which order.

I am familiar with the "read" command, and have successfully constructed a simple prompt. However, due to the inherent nature of shell scripts, the prompt is only capable of going forward; ie question #1 is asked, and once an answer is entered, question #2 is asked. The user is not able to then go back to question #1, unless he/she quits and starts over.

Does anyone have any ideas on how to do this? Is there a command that orders the shell to jump backward/forward to a specific line number of the script? My thought is that if the user enters for example "b" (for back), the shell would then skip so many line #'s back in the script to where the previous question was asked. Any other ideas?

Thanks for any help,
Mike

One way to do it:

Each step would be a function. Then you have a main loop that counts which step you're at. If the user enters "b" it will subtract 1 from the counter and then call the function associated with that step.

Hi kodak,

That is a pretty cool suggestion. I had thought of making each question be a separate script and doing something similar, but this sounds much more efficient.

So I assume you would initially define all of the functions, then have a "while" loop which would be exited once the counter exceeded the number of questions?

Thanks again.