aboutsummaryrefslogtreecommitdiff
path: root/libbutl
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-02-27 14:43:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-02-27 14:43:57 +0200
commitf527705103d38264aa40557e7866a99cfa138f88 (patch)
treeaf322dcf393af37c44e533ac6e646ff349fb57ec /libbutl
parentdbce2c5f242173838bffff4fa2268c26bd5d96df (diff)
Accept both lower and upper case y/n as valid answers in yn_prompt()
Diffstat (limited to 'libbutl')
-rw-r--r--libbutl/prompt.cxx4
-rw-r--r--libbutl/prompt.hxx4
2 files changed, 6 insertions, 2 deletions
diff --git a/libbutl/prompt.cxx b/libbutl/prompt.cxx
index 2e42dd5..154522c 100644
--- a/libbutl/prompt.cxx
+++ b/libbutl/prompt.cxx
@@ -44,8 +44,8 @@ namespace butl
if (!e)
a = def;
}
- } while (a != "y" && a != "n");
+ } while (a != "y" && a != "Y" && a != "n" && a != "N");
- return a == "y";
+ return a == "y" || a == "Y";
}
}
diff --git a/libbutl/prompt.hxx b/libbutl/prompt.hxx
index 90b8dbf..2a07708 100644
--- a/libbutl/prompt.hxx
+++ b/libbutl/prompt.hxx
@@ -15,6 +15,10 @@ namespace butl
// Write the prompt to diag_stream. Throw ios_base::failure if no answer
// could be extracted from stdin (for example, because it was closed).
//
+ // Note that the implementation accepts both lower and upper case y/n as
+ // valid answers (apparently the capitalized default answer confuses some
+ // users into answering with capital letters).
+ //
LIBBUTL_SYMEXPORT bool
yn_prompt (const std::string&, char def = '\0');
}