diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-05-13 13:55:07 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-05-13 13:55:07 +0200 |
| commit | 9d4f8aaceda37364748a4be8238ffde4c137a19c (patch) | |
| tree | 0c641bbf257f606503edd04c3d4a1fd1fd559e62 /service/src/util.c | |
| parent | f1285b65d59119b71c7c4f98dddcf2d6969922be (diff) | |
| download | enowars5-service-stldoctor-9d4f8aaceda37364748a4be8238ffde4c137a19c.tar.gz enowars5-service-stldoctor-9d4f8aaceda37364748a4be8238ffde4c137a19c.zip | |
added cleanup script, improved poc test, addec echo for debugging and small fixes
Diffstat (limited to 'service/src/util.c')
| -rw-r--r-- | service/src/util.c | 6 |
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; } |
