aboutsummaryrefslogtreecommitdiffstats
path: root/service/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'service/src/util.c')
-rw-r--r--service/src/util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/service/src/util.c b/service/src/util.c
index 9f91f6b..c53f92b 100644
--- a/service/src/util.c
+++ b/service/src/util.c
@@ -106,7 +106,11 @@ ask(const char *fmtstr, ...)
fail = !fgets(linebuf, sizeof(linebuf), stdin);
- if (!fail) linebuf[strlen(linebuf) - 1] = '\0';
+ if (!fail && *linebuf) {
+ if (linebuf[strlen(linebuf)-1] == '\n')
+ linebuf[strlen(linebuf)-1] = '\0';
+ if (echo) printf("%s\n", linebuf);
+ }
return fail ? "" : linebuf;
}