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:
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, "\n[0mWrite error: %s\n", strerror(errno));
+ fprintf(stderr, "\n[0mlolcat: Write error: %s\n", strerror(errno));
return 1;
}
}
if(c == EOF && errno != 0)
{
- fprintf(stderr, "\n[0mRead error: %s\n", strerror(errno));
+ fprintf(stderr, "\n[0mlolcat: Read error: %s\n", strerror(errno));
return 1;
}
@@ -86,7 +86,7 @@ main(int argc, char *argv[])
if(!file)
{
- fprintf(stderr, "\n[0mError opening ‘%s’: %s\n", argv[argi], strerror(errno));
+ fprintf(stderr, "\n[0mlolcat: 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:\n[0mRead error: Inappropriate ioctl for device\n' -o 'inline:[0m' ../cmd/lolcat /dev/null
- atf_check -s exit:1 -e 'inline:\n[0mRead error: Inappropriate ioctl for device\n' -o 'inline:[0m' ../cmd/lolcat </dev/null
- atf_check -s exit:1 -e 'inline:\n[0mRead error: Inappropriate ioctl for device\n' -o 'inline:[0m' ../cmd/lolcat - </dev/null
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Read error: Inappropriate ioctl for device\n' -o 'inline:[0m' ../cmd/lolcat /dev/null
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Read error: Inappropriate ioctl for device\n' -o 'inline:[0m' ../cmd/lolcat </dev/null
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Read error: Inappropriate ioctl for device\n' -o 'inline:[0m' ../cmd/lolcat - </dev/null
else
atf_check -o 'inline:[0m' ../cmd/lolcat /dev/null
atf_check -o 'inline:[0m' ../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:\n[0mError opening ‘inputs/chmod_000’: Permission denied\n' -o 'inline:[0m' ../cmd/lolcat inputs/chmod_000
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Error opening ‘inputs/chmod_000’: Permission denied\n' -o 'inline:[0m' ../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:\n[0mError writing: No space left on device\n' sh -c '../cmd/lolcat inputs/all_bytes >/dev/full'
- atf_check -s exit:1 -e 'inline:\n[0mError writing: No space left on device\n' sh -c '../cmd/lolcat <inputs/all_bytes >/dev/full'
- atf_check -s exit:1 -e 'inline:\n[0mError writing: No space left on device\n' sh -c '../cmd/lolcat - <inputs/all_bytes >/dev/full'
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Error writing: No space left on device\n' sh -c '../cmd/lolcat inputs/all_bytes >/dev/full'
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Error writing: No space left on device\n' sh -c '../cmd/lolcat <inputs/all_bytes >/dev/full'
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: 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:\n[0mRead error: Is a directory\n' -o 'inline:[0m' ../cmd/lolcat ./
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Read error: Is a directory\n' -o 'inline:[0m' ../cmd/lolcat ./
}
atf_test_case enoent
enoent_body() {
# shellcheck disable=SC1112
- atf_check -s exit:1 -e 'inline:\n[0mError opening ‘/var/empty/e/no/ent’: No such file or directory\n' -o 'inline:[0m' ../cmd/lolcat /var/empty/e/no/ent
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Error opening ‘/var/empty/e/no/ent’: No such file or directory\n' -o 'inline:[0m' ../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:\n[0mError opening ‘---’: No such file or directory\n' -o 'inline:[0m' -- ../cmd/lolcat --- inputs/all_bytes
+ atf_check -s exit:1 -e 'inline:\n[0mlolcat: Error opening ‘---’: No such file or directory\n' -o 'inline:[0m' -- ../cmd/lolcat --- inputs/all_bytes
}
atf_init_test_cases() {