Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support typing "exit" or "quit" means exit from REPL. #19021

Closed
Yanhao opened this issue Feb 27, 2018 · 5 comments
Closed

Support typing "exit" or "quit" means exit from REPL. #19021

Yanhao opened this issue Feb 27, 2018 · 5 comments
Labels
feature request Issues that request new features to be added to Node.js. repl Issues and PRs related to the REPL subsystem.

Comments

@Yanhao
Copy link

Yanhao commented Feb 27, 2018

And why nodejs doesn't know that?

@devsnek
Copy link
Member

devsnek commented Feb 27, 2018

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

@devsnek devsnek added question Issues that look for answers. repl Issues and PRs related to the REPL subsystem. labels Feb 27, 2018
@Yanhao
Copy link
Author

Yanhao commented Feb 27, 2018

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.

@gibfahn
Copy link
Member

gibfahn commented Mar 5, 2018

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.

@bnoordhuis bnoordhuis added feature request Issues that request new features to be added to Node.js. and removed question Issues that look for answers. labels Mar 5, 2018
@MylesBorins MylesBorins changed the title Everyone in the world knows that typing "exit" or "quit" means exit from REPL. Support typing "exit" or "quit" means exit from REPL. Mar 13, 2018
@MylesBorins
Copy link
Contributor

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

@codeblooded
Copy link

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’ll 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’s defined in the scope (which may cause confusion)
  3. A noninvasive reminder of the current way to exit the repl

monkingxue added a commit to monkingxue/node that referenced this issue May 18, 2018
Imitate python repl, when the user enters 'exit' or 'quit',
no longer prompt 'Reference Error', but
prompts 'To exit, press ^D or type .exit'.
If the user defines variables named 'exit' or 'quit' ,
only the value of the variables are output

Fixes: nodejs#19021
MylesBorins pushed a commit that referenced this issue May 22, 2018
Imitate python repl, when the user enters 'exit' or 'quit',
no longer prompt 'Reference Error', but
prompts 'To exit, press ^D or type .exit'.
If the user defines variables named 'exit' or 'quit' ,
only the value of the variables are output

PR-URL: #20617
Fixes: #19021
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants