Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/trepl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Beyer <lucasb.eyer.be@gmail.com>2015-12-07 19:45:55 +0300
committerLucas Beyer <lucasb.eyer.be@gmail.com>2015-12-07 19:45:55 +0300
commit3c6b32c29a29e4837690e8ec9d445b0d4933dcc7 (patch)
treec2b895752a3239739de00cc93f660efc13529c07
parent0aff06c7b3ba291c86fd9e861258e56397885be5 (diff)
Allow quitting with double Ctrl+D
I'm used to this feature from IPython/Jupyter and since here you also quit on empty string, I see no harm? Without this change, doing double Ctrl+D would get: ``` th> Do you really want to exit ([y]/n)? /home.local/lucas/inst/src/torch/install/bin/luajit: ...ucas/inst/src/torch/install/share/lua/5.1/trepl/init.lua:587: attempt to index local 'line' (a nil value) stack traceback: ...ucas/inst/src/torch/install/share/lua/5.1/trepl/init.lua:587: in function 'repl' .../src/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk [C]: at 0x00406670 ```
-rw-r--r--init.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 06e57e1..a043fe5 100644
--- a/init.lua
+++ b/init.lua
@@ -584,7 +584,7 @@ function repl()
if not line or line == 'exit' then
io.write('Do you really want to exit ([y]/n)? ') io.flush()
local line = io.read('*l')
- if line == '' or line:lower() == 'y' then
+ if not line or line == '' or line:lower() == 'y' then
os.exit()
end
end