logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 096682cd9d0dd45b90c64a06066f2281622c14dd
parent 33683e867a13b0e9d65bf1fb305d766807307ddb
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 20 Sep 2024 05:17:50 +0200

lib/consent: unify error message formatting

Diffstat:

Mlib/consent.c19+++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/consent.c b/lib/consent.c @@ -28,8 +28,11 @@ consent_init(void) { char errstr[64] = ""; regerror(yesexpr_ret, &consent_yesexpr_r, errstr, 100); - fprintf( - stderr, "%s: Got errorneous yesexpr regex /%s/ from locale: %s\n", argv0, yesexpr, errstr); + fprintf(stderr, + "%s: warning: Got errorneous yesexpr regex /%s/ from locale: %s\n", + argv0, + yesexpr, + errstr); errno = 0; fprintf(stderr, "%s: Fallbacking to /^[Yy]/\n", argv0); @@ -44,8 +47,11 @@ consent_init(void) { char errstr[64] = ""; regerror(noexpr_ret, &consent_noexpr_r, errstr, 100); - fprintf( - stderr, "%s: Got errorneous noexpr regex /%s/ from locale: %s\n", argv0, noexpr, errstr); + fprintf(stderr, + "%s: warning: Got errorneous noexpr regex /%s/ from locale: %s\n", + argv0, + noexpr, + errstr); errno = 0; fprintf(stderr, "%s: Fallbacking to /^[Nn]/\n", argv0); @@ -79,7 +85,7 @@ consentf(const char *restrict fmt, ...) if(ret < 0) { - fprintf(stderr, "%s: Failed to print user prompt: %s\n", argv0, strerror(errno)); + fprintf(stderr, "%s: error: Failed to print user prompt: %s\n", argv0, strerror(errno)); errno = 0; goto end; } @@ -88,7 +94,8 @@ consentf(const char *restrict fmt, ...) ssize_t nread = getline(&line, &len, stdin); if(nread < 0) { - fprintf(stderr, "\n%s: Failed getting user entry via getline: %s\n", argv0, strerror(errno)); + fprintf( + stderr, "\n%s: error: Failed getting user entry via getline: %s\n", argv0, strerror(errno)); errno = 0; goto end; }