[lldb/Lua] Recognize "quit" as a way to exit the script interpreter.

Add a way to quit the interactive script interpreter from a shell tests.
Currently, the only way (that I know) to exit the interactive Lua
interpreter is to send a EOF with CTRL-D. I noticed that the embedded
Python script interpreter accepts quit (while the regular python
interpreter doesn't). I've added a special case to the Lua interpreter
to do the same.

Differential revision: https://reviews.llvm.org/D82272
This commit is contained in:
Jonas Devlieghere 2020-06-21 00:31:46 -07:00
parent 9934cc544c
commit 1728dec255
2 changed files with 15 additions and 0 deletions

View File

@ -39,6 +39,11 @@ public:
void IOHandlerInputComplete(IOHandler &io_handler,
std::string &data) override {
if (llvm::StringRef(data).rtrim() == "quit") {
io_handler.SetIsDone(true);
return;
}
if (llvm::Error error = m_script_interpreter.GetLua().Run(data)) {
*GetOutputStreamFileSP() << llvm::toString(std::move(error));
}

View File

@ -0,0 +1,10 @@
# REQUIRES: lua
# UNSUPPORTED: lldb-repro
#
# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
script
print(95000 + 126)
quit
target list
# CHECK: 95126
# CHECK: No targets