Home > OS >  How to exit a REPL from the command line
How to exit a REPL from the command line

Time:06-04

I'm currently learning Lua and also learning how to work with CMD. I know how to change a directory path and run my codes and files from that path but what I don't know and I'm here to ask for is how to get out of a programming language REPL when you start it in CMD

For example to jump into the Lua REPL you should type:

lua53 (--like python3 for the Python language) 

then you changed the CMD environment to a Lua compiler and can't access CMD commands such as dir, cd, cls etc. and everytime when I need to access these commands I have to close the CMD window and open a new one. Now can you guys tell me am I able to access CMD commands while in the Lua REPL? Or do I have to exit Lua first, and is there any command to exit a REPL?

CodePudding user response:

I'd recommend EOF (Ctrl D on Unix) rather than SIGKILL (Ctrl C) because some REPLs (node and python) choose to ignore the latter (perhaps because it's often used for copying text?); python will just print KeyboardInterrupt whereas node will only exit if you press Ctrl C twice (it will send a message telling you this the first time).

EOF (Ctrl D) on the other hand immediately exists all REPLs I have used so far.

The Lua REPL stops immediately when it receives either EOF or SIGKILL, so you can use both here.

Edit: As Sowban points out, EOF apparently is entered as Ctrl Z then Enter in powershell.

CodePudding user response:

You could type ctrl c to exit the process that's running generally.

  • Related