commit: c899b4a8d9705d90415ce8ef735db7c2f33650a1
parent 192f297ce8cac1e1a9b7cae51f45044e191ed4be
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 24 Sep 2022 05:38:03 +0200
cmd/tee: Always prefix error message with "tee: "
Diffstat:
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/cmd/tee.c b/cmd/tee.c
@@ -47,7 +47,7 @@ main(int argc, char *argv[])
if(!fds)
{
- fprintf(stderr, "Cannot allocate fd array: %s\n", strerror(errno));
+ fprintf(stderr, "tee: Cannot allocate fd array: %s\n", strerror(errno));
return 1;
}
}
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
if(fds[argi] == NULL)
{
- fprintf(stderr, "Error opening ‘%s’: %s\n", argv[argi], strerror(errno));
+ fprintf(stderr, "tee: Error opening ‘%s’: %s\n", argv[argi], strerror(errno));
cleanup(fds);
return 1;
}
@@ -74,7 +74,7 @@ main(int argc, char *argv[])
{
if(fputc(c, stdout) == EOF)
{
- fprintf(stderr, "Error writing ‘<stdout>’: %s\n", strerror(errno));
+ fprintf(stderr, "tee: Error writing ‘<stdout>’: %s\n", strerror(errno));
err = 1;
errno = 0;
}
@@ -83,7 +83,7 @@ main(int argc, char *argv[])
{
if(fputc(c, fds[argi]) == EOF)
{
- fprintf(stderr, "Error writing to argument %d: %s\n", argi, strerror(errno));
+ fprintf(stderr, "tee: Error writing to argument %d: %s\n", argi, strerror(errno));
err = 1;
errno = 0;
}
diff --git a/test-cmd/tee b/test-cmd/tee
@@ -33,7 +33,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:Error opening ‘inputs/chmod_000’: Permission denied\n' ../cmd/tee inputs/chmod_000 </dev/null
+ atf_check -s exit:1 -e 'inline:tee: Error opening ‘inputs/chmod_000’: Permission denied\n' ../cmd/tee inputs/chmod_000 </dev/null
}
noperm_cleanup() {
chmod 0600 inputs/chmod_000 || atf_fail "chmod 0600 chmod_000"
@@ -47,9 +47,9 @@ devfull_body() {
[ "$(uname -s)" = "FreeBSD" ] && atf_expect_fail "FreeBSD ignoring write errors for fputs()"
# shellcheck disable=SC1112
- atf_check -s exit:1 -e 'inline:Error writing ‘<stdout>’: No space left on device\n' sh -c '../cmd/tee <inputs/all_bytes >/dev/full'
+ atf_check -s exit:1 -e 'inline:tee: Error writing ‘<stdout>’: No space left on device\n' sh -c '../cmd/tee <inputs/all_bytes >/dev/full'
# shellcheck disable=SC1112
- atf_check -s exit:1 -e 'inline:Error writing ‘<stdout>’: No space left on device\n' sh -c '../cmd/tee - <inputs/all_bytes >/dev/full'
+ atf_check -s exit:1 -e 'inline:tee: Error writing ‘<stdout>’: No space left on device\n' sh -c '../cmd/tee - <inputs/all_bytes >/dev/full'
}
atf_test_case nullinput
@@ -60,19 +60,19 @@ nullinput_body() {
atf_test_case writeslash
writeslash_body() {
# shellcheck disable=SC1112
- atf_check -s exit:1 -e 'inline:Error opening ‘./’: Is a directory\n' ../cmd/tee ./ <inputs/all_bytes
+ atf_check -s exit:1 -e 'inline:tee: Error opening ‘./’: Is a directory\n' ../cmd/tee ./ <inputs/all_bytes
}
atf_test_case enoent
enoent_body() {
# shellcheck disable=SC1112
- atf_check -s exit:1 -e 'inline:Error opening ‘/var/empty/e/no/ent’: No such file or directory\n' ../cmd/tee /var/empty/e/no/ent <inputs/all_bytes
+ atf_check -s exit:1 -e 'inline:tee: Error opening ‘/var/empty/e/no/ent’: No such file or directory\n' ../cmd/tee /var/empty/e/no/ent <inputs/all_bytes
}
atf_test_case doubledash
doubledash_body() {
atf_check -o file:inputs/all_bytes -- ../cmd/tee -- <inputs/all_bytes
- #atf_check -s exit:1 -e 'inline:Error opening ‘---’: No such file or directory\n' -o empty -- ../cmd/tee --- <inputs/all_bytes
+ #atf_check -s exit:1 -e 'inline:tee: Error opening ‘---’: No such file or directory\n' -o empty -- ../cmd/tee --- <inputs/all_bytes
}