镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@Yanhao

And why nodejs doesn't know that?

Activity

  1. devsnek commented on Feb 27, 2018

    @devsnek
    Member

    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

  2. added
    questionIssues asking questions about Node.js.
    replIssues and PRs related to the REPL subsystem.
    on Feb 27, 2018
  3. Yanhao commented on Feb 27, 2018

    @Yanhao
    Author

    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.

  4. gibfahn commented on Mar 5, 2018

    @gibfahn
    Member

    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.

  5. added
    feature requestIssues requesting new Node.js features.
    and removed
    questionIssues asking questions about Node.js.
    on Mar 5, 2018
  6. 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.[/+] on Mar 13, 2018
  7. MylesBorins commented on Mar 13, 2018

    @MylesBorins
    Contributor

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

  8. codeblooded commented on Apr 13, 2018

    @codeblooded

    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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions