Hi wisecracker,
Please don't impose your method of performing this task on Nastybutler. Let Nastybutler choose whatever increment he wants. Either of the obvious choices can yield perfectly fine results for this task and as soon as the syntax error is resolved, the logic errors are likely to reveal themselves very quickly. Infinite loops tend to become obvious quickly when there is an
echo inside that loop.
As RudiC said in Nastybutler's other thread, if the goal here was to write efficient code, there would be no requirement for a
while loop. It appears that the goal of this assignment is to learn how to correctly write a
while loop. Whether or not that
while loop contains an
if statement isn't the point.
With the error that Nastybutler is currently seeing, there are three likely things that could be causing the problem:
- A syntax error in the if statement.
- A syntax error in the statement before the fi keyword that wasn't fully diagnosed until the fi was seen.
- Or, something like a carriage-return in a DOS line terminating <carriage-return><newline> character pair when a single-character <newline> UNIX line terminator was expected on one of the two lines before the fi.
Like you, I'm guessing that the problem is point #2 above, especially since the shell I use complains about an unexpected "(" two lines before the spot that the shell Nastybutler is using complains about something "
near the unexpected token `fi'". But, if adding the missing character to line 12 doesn't solve the problem, #3 above becomes a real possibility.