~kennylevinsen/greetd-devel

agreety: Return error if no input when prompted v1 APPLIED

Jonathan Sköld: 1
 agreety: Return error if no input when prompted

 1 files changed, 1 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~kennylevinsen/greetd-devel/patches/40174/mbox | git am -3
Learn more about email & git

[PATCH] agreety: Return error if no input when prompted Export this patch

From: Jonathan Sköld <git@skold.dev>

If EOF is provided when the user is prompted agreety would panic. This
commit fixes that by returning an error instead causing graceful exit(1)
instead.
---
 agreety/src/main.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/agreety/src/main.rs b/agreety/src/main.rs
index 2a8ad5e..22ff87e 100644
--- a/agreety/src/main.rs
+++ b/agreety/src/main.rs
@@ -22,7 +22,7 @@ fn prompt_stderr(prompt: &str) -> Result<String, Box<dyn std::error::Error>> {
    let stdin = io::stdin();
    let mut stdin_iter = stdin.lock().lines();
    eprint!("{}", prompt);
    Ok(stdin_iter.next().unwrap()?)
    Ok(stdin_iter.next().ok_or("no input")??)
}

fn get_distro_name() -> Result<String, Box<dyn std::error::Error>> {
-- 
2.40.0
Applied, thanks!