aboutsummaryrefslogtreecommitdiff
path: root/builtins/functions.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-04 15:03:54 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-04 15:03:54 -0400
commit11b484a6a2077ba6bd8fdbbf46e589449cc5e251 (patch)
tree7809960c4e6954e028035e2b46011f1e2b7ff594 /builtins/functions.c
parent05bc754679ca5b136b2f3a70b791db71e9260234 (diff)
Document ask()
Diffstat (limited to 'builtins/functions.c')
-rw-r--r--builtins/functions.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/builtins/functions.c b/builtins/functions.c
index b69f81d9..b6132494 100644
--- a/builtins/functions.c
+++ b/builtins/functions.c
@@ -264,13 +264,19 @@ public Text_t ask(Text_t prompt, bool bold, bool force_tty)
if (force_tty && !isatty(STDIN_FILENO)) {
in = fopen("/dev/tty", "r");
- if (!in) goto cleanup;
+ if (!in) {
+ fputs("\n", out); // finish the line, since the user can't
+ goto cleanup;
+ }
}
char *line = NULL;
size_t bufsize = 0;
ssize_t length = getline(&line, &bufsize, in);
- if (length == -1) goto cleanup;
+ if (length == -1) {
+ fputs("\n", out); // finish the line, since we didn't get any input
+ goto cleanup;
+ }
if (length > 0 && line[length-1] == '\n') {
line[length-1] = '\0';