logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 32fcdc0f256c69087302e254e575ab752914305f
parent a558f0702d8d1bdec0af5bde8f77c15440e66f1b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 24 Sep 2022 05:32:19 +0200

cmd/lolcat: Always prefix error message with "lolcat: "

Diffstat:

Mcmd/lolcat.c6+++---
Mtest-cmd/lolcat20++++++++++----------
2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cmd/lolcat.c b/cmd/lolcat.c @@ -41,14 +41,14 @@ concat(FILE *stream) if(fputc(c, stdout) == EOF) { - fprintf(stderr, "\nWrite error: %s\n", strerror(errno)); + fprintf(stderr, "\nlolcat: Write error: %s\n", strerror(errno)); return 1; } } if(c == EOF && errno != 0) { - fprintf(stderr, "\nRead error: %s\n", strerror(errno)); + fprintf(stderr, "\nlolcat: Read error: %s\n", strerror(errno)); return 1; } @@ -86,7 +86,7 @@ main(int argc, char *argv[]) if(!file) { - fprintf(stderr, "\nError opening ‘%s’: %s\n", argv[argi], strerror(errno)); + fprintf(stderr, "\nlolcat: Error opening ‘%s’: %s\n", argv[argi], strerror(errno)); ret = 1; goto end; } diff --git a/test-cmd/lolcat b/test-cmd/lolcat @@ -21,9 +21,9 @@ atf_test_case devnull devnull_body() { if [ "$(uname -s)" = "FreeBSD" ] || [ "$(uname -s)" = "NetBSD" ]; then # FIXME - atf_check -s exit:1 -e 'inline:\nRead error: Inappropriate ioctl for device\n' -o 'inline:' ../cmd/lolcat /dev/null - atf_check -s exit:1 -e 'inline:\nRead error: Inappropriate ioctl for device\n' -o 'inline:' ../cmd/lolcat </dev/null - atf_check -s exit:1 -e 'inline:\nRead error: Inappropriate ioctl for device\n' -o 'inline:' ../cmd/lolcat - </dev/null + atf_check -s exit:1 -e 'inline:\nlolcat: Read error: Inappropriate ioctl for device\n' -o 'inline:' ../cmd/lolcat /dev/null + atf_check -s exit:1 -e 'inline:\nlolcat: Read error: Inappropriate ioctl for device\n' -o 'inline:' ../cmd/lolcat </dev/null + atf_check -s exit:1 -e 'inline:\nlolcat: Read error: Inappropriate ioctl for device\n' -o 'inline:' ../cmd/lolcat - </dev/null else atf_check -o 'inline:' ../cmd/lolcat /dev/null atf_check -o 'inline:' ../cmd/lolcat </dev/null @@ -36,7 +36,7 @@ noperm_body() { touch inputs/chmod_000 || atf_fail "touching chmod_000" chmod 0000 inputs/chmod_000 || atf_fail "chmod 0000 chmod_000" # shellcheck disable=SC1112 - atf_check -s exit:1 -e 'inline:\nError opening ‘inputs/chmod_000’: Permission denied\n' -o 'inline:' ../cmd/lolcat inputs/chmod_000 + atf_check -s exit:1 -e 'inline:\nlolcat: Error opening ‘inputs/chmod_000’: Permission denied\n' -o 'inline:' ../cmd/lolcat inputs/chmod_000 } noperm_cleanup() { chmod 0600 inputs/chmod_000 || atf_fail "chmod 0600 chmod_000" @@ -49,9 +49,9 @@ devfull_body() { [ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD badly handling write errors" [ "$(uname -s)" = "NetBSD" ] && atf_expect_fail "NetBSD badly handling write errors" - atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../cmd/lolcat inputs/all_bytes >/dev/full' - atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../cmd/lolcat <inputs/all_bytes >/dev/full' - atf_check -s exit:1 -e 'inline:\nError writing: No space left on device\n' sh -c '../cmd/lolcat - <inputs/all_bytes >/dev/full' + atf_check -s exit:1 -e 'inline:\nlolcat: Error writing: No space left on device\n' sh -c '../cmd/lolcat inputs/all_bytes >/dev/full' + atf_check -s exit:1 -e 'inline:\nlolcat: Error writing: No space left on device\n' sh -c '../cmd/lolcat <inputs/all_bytes >/dev/full' + atf_check -s exit:1 -e 'inline:\nlolcat: Error writing: No space left on device\n' sh -c '../cmd/lolcat - <inputs/all_bytes >/dev/full' } atf_test_case readslash @@ -59,20 +59,20 @@ readslash_body() { [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD allows to read directories" # shellcheck disable=SC1112 - atf_check -s exit:1 -e 'inline:\nRead error: Is a directory\n' -o 'inline:' ../cmd/lolcat ./ + atf_check -s exit:1 -e 'inline:\nlolcat: Read error: Is a directory\n' -o 'inline:' ../cmd/lolcat ./ } atf_test_case enoent enoent_body() { # shellcheck disable=SC1112 - atf_check -s exit:1 -e 'inline:\nError opening ‘/var/empty/e/no/ent’: No such file or directory\n' -o 'inline:' ../cmd/lolcat /var/empty/e/no/ent + atf_check -s exit:1 -e 'inline:\nlolcat: Error opening ‘/var/empty/e/no/ent’: No such file or directory\n' -o 'inline:' ../cmd/lolcat /var/empty/e/no/ent } atf_test_case doubledash doubledash_body() { atf_check -o file:outputs/lolcat/all_bytes -- ../cmd/lolcat -- inputs/all_bytes # shellcheck disable=SC1112 - atf_check -s exit:1 -e 'inline:\nError opening ‘---’: No such file or directory\n' -o 'inline:' -- ../cmd/lolcat --- inputs/all_bytes + atf_check -s exit:1 -e 'inline:\nlolcat: Error opening ‘---’: No such file or directory\n' -o 'inline:' -- ../cmd/lolcat --- inputs/all_bytes } atf_init_test_cases() {