Node: Support typing "exit" or "quit" means exit from REPL.

Created on 27 Feb 2018  路  5Comments  路  Source: nodejs/node

And why nodejs doesn't know that?

feature request repl

Most helpful comment

Would you all be opposed to prompting for clarification? The repl makes you type CMD-C twice to exit.

You could do something like:

> exit
Did you mean '.exit' [Y/n]? 

It could default to YES, so, if they simply press return, they鈥檒l exit. If they say NO, it will proceed to run as if exit is a reference.

Benefits:

  1. No addition of restricted words (quit or exit may be a function that the user defined)
  2. No conditional logic based on what鈥檚 defined in the scope (which may cause confusion)
  3. A noninvasive reminder of the current way to exit the repl

All 5 comments

exit and quit could be variable names so we have .exit. we could do what python does and show a warning when those keywords are asked for without being assigned

we could do what python does and show a warning when those keywords are asked for without being assigned

that's better, or you could forbid people to define global variable named "quit" or "exit" only in REPL just like what ipython already did and that is considered user friendly.

Agreed that this isn't a great user experience.

image

ReferenceError: quit is not defined

I'd assume the chances of someone typing quit or exit by themselves into the repl, when they're not defined, and not wanting to quit the repl should be vanishingly rare.

I've modified the title to be a little bit more friendly.

Would you all be opposed to prompting for clarification? The repl makes you type CMD-C twice to exit.

You could do something like:

> exit
Did you mean '.exit' [Y/n]? 

It could default to YES, so, if they simply press return, they鈥檒l exit. If they say NO, it will proceed to run as if exit is a reference.

Benefits:

  1. No addition of restricted words (quit or exit may be a function that the user defined)
  2. No conditional logic based on what鈥檚 defined in the scope (which may cause confusion)
  3. A noninvasive reminder of the current way to exit the repl
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Brekmister picture Brekmister  路  3Comments

seishun picture seishun  路  3Comments

filipesilvaa picture filipesilvaa  路  3Comments

fanjunzhi picture fanjunzhi  路  3Comments

addaleax picture addaleax  路  3Comments