Monolune

Truly Interactive Shells

This article is about shells that refuse to correct mistakes.

Today, a shell refused to give me a chance to correct a mistake. Instead, it immediately terminated.

This is what I entered and the result that I got:

>> 12 / 0
Error: Division by zero in '12 / 0'. Cannot divide by zero.

An error because of a division by zero. That is all normal, but think. Think. If the interpreter/compiler/environment knows that division by zero is wrong, why can't it offer to fix it for us? I was expecting something like:

>> 12 / 0
Error: Division by zero in '12 / 0'. Cannot divide by zero.
Divide by something else instead? 3
>>>> 12 / 3
4

The point is: if the interpreter knows that there is a mistake, why does it not ask for a correction and then proceed to execute normally?

Another illustrative example that leads to a termination:

>> disply "Great!"
Error. 'disply' is not known.
Perhaps you meant 'display'.

It correctly identifies the mistake but does not offer to fix the problem. The program terminates. There wasn't a chance to correct a mistake at the point of error.

The same pattern can be observed when running unit tests that fail. The system does not normally offer ways to fix the problem to make the unit tests pass.

It should be a simple task to just ask for a correction of the value, and yet I don't see this often. In the little world I live in, when a mistake is encountered, the system running the program would politely ask for a correction and proceed with running the rest of the program. I don't understand why the systems we use do not offer to correct mistakes. Maybe I'm still a beginner. I have been a beginner for some time now, but when will I ever understand? When?

Edit: I have written an article on examples of interactive shells.