Mercurial > prosody-hg
comparison util/prosodyctl/shell.lua @ 12862:3dfb87814d65 0.12
util.prosodyctl.shell: Close state on exit to fix saving shell history
This ensures a last round of garbage collection and finalizers, which
should include flushing the readline history file.
Test procedure:
```
$ ./prosodyctl shell
prosody> s2s:show() -- any command that is not the last in history
... output
prosody> bye
$ ./prosodyctl shell
prosody> ^P
```
After this, the shell prompt should contain the last command from before
the "bye". Before this patch, recent history is gone most of the time.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 22 Jan 2023 14:42:07 +0100 |
| parents | 98fd531594bd |
| children | 9f9633364044 |
comparison
equal
deleted
inserted
replaced
| 12859:cd738fb8c754 | 12862:3dfb87814d65 |
|---|---|
| 37 print(""); | 37 print(""); |
| 38 end | 38 end |
| 39 if have_readline then | 39 if have_readline then |
| 40 readline.save_history(); | 40 readline.save_history(); |
| 41 end | 41 end |
| 42 os.exit(); | 42 os.exit(0, true); |
| 43 end | 43 end |
| 44 send_line(client, line); | 44 send_line(client, line); |
| 45 end | 45 end |
| 46 | 46 |
| 47 local function printbanner() | 47 local function printbanner() |
| 110 repl(client); | 110 repl(client); |
| 111 end); | 111 end); |
| 112 | 112 |
| 113 client.events.add_handler("disconnected", function () | 113 client.events.add_handler("disconnected", function () |
| 114 print("--- session closed ---"); | 114 print("--- session closed ---"); |
| 115 os.exit(); | 115 os.exit(0, true); |
| 116 end); | 116 end); |
| 117 | 117 |
| 118 client.events.add_handler("received", function (stanza) | 118 client.events.add_handler("received", function (stanza) |
| 119 if stanza.name == "repl-output" or stanza.name == "repl-result" then | 119 if stanza.name == "repl-output" or stanza.name == "repl-result" then |
| 120 local result_prefix = stanza.attr.type == "error" and "!" or "|"; | 120 local result_prefix = stanza.attr.type == "error" and "!" or "|"; |
