codesoap: 2
Do not show error message on exit through CTRL-D
Do not show error message on exit through CTRL-D
2 files changed, 11 insertions(+), 2 deletions(-)
---
First time using git send-email; hope this works... Thanks for writing
this gemini client, it's my favourite so far, after trying most of the
"mainstream" ones! I usually exit programs, that give me readlines with
CTRL-D. Before this patch, gelim would exit on CTRL-D, but also display
an error message.
gelim.go | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gelim.go b/gelim.go
index 1953c30..3f6938c 100644
--- a/gelim.go+++ b/gelim.go
@@ -151,7 +151,11 @@ func main() {
}
color.Unset()
- if err != nil {+ if err == io.EOF {+ // Exit by CTRL-D.+ fmt.Println("")+ c.QuitClient(0)+ } else if err != nil { if err != ln.ErrPromptAborted {
c.style.ErrorMsg("error reading line input: " + err.Error())
}
This looks good but it would be amazing if we could refactor it
to put checking for io.EOF together with checking for ln.ErrPromotAborted.
So line 154 would be untouched, and line 155 could be something like:
if err != ln.ErrPromptAborted && err != io.EOF {
I haven't tested it though, if you'd like to keep the fmt.Println
line you can put it right under `err != nil` so a new line is
printed regardless of the error.
Do you know how to send a v2? I hope you'll figure it out, good luck!
(oops I didn't reply all, ignore the double email)
***
Hi! Sorry for the delay. Your patch sent successfully :)
I'm glad it's your favorite client. It's a pity that I haven't
been able to work on it for quite a long time due to IRL issues,
but I'm sure I'll find time for it real soon.
[PATCH gelim] Do not show error message on exit through CTRL-D
Export this patch
---
Is this what you had in mind? I would still add an additional 'if' to
exit with exit code 0 on CTLR-D.
gelim.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gelim.go b/gelim.go
index 1953c30..066a2ec 100644
--- a/gelim.go+++ b/gelim.go
@@ -152,9 +152,14 @@ func main() {
color.Unset()
if err != nil {
- if err != ln.ErrPromptAborted {+ if err != ln.ErrPromptAborted && err != io.EOF { c.style.ErrorMsg("error reading line input: " + err.Error())
}
+ fmt.Println("")+ if err == io.EOF {+ // Exit by CTRL-D.+ c.QuitClient(0)+ } // Exiting because it will cause an infinite loop of error if used 'continue' here
c.QuitClient(1)
}
--
2.33.0