logo

utils

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

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

Diffstat:

Mcmd/xcd.c6+++---
Mtest-cmd/xcd8++++----
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/cmd/xcd.c b/cmd/xcd.c @@ -194,7 +194,7 @@ concat(FILE *stream) return 0; werr: - fprintf(stderr, "\nWrite error: %s\n", strerror(errno)); + fprintf(stderr, "\nxcd: Write error: %s\n", strerror(errno)); return 1; } @@ -228,7 +228,7 @@ main(int argc, char *argv[]) FILE *file = fopen(argv[argi], "r"); if(!file) { - fprintf(stderr, "\nError opening ‘%s’: %s\n", argv[argi], strerror(errno)); + fprintf(stderr, "\nxcd: Error opening ‘%s’: %s\n", argv[argi], strerror(errno)); err = 1; goto cleanup; } @@ -239,7 +239,7 @@ main(int argc, char *argv[]) if(err != 0) { - fprintf(stderr, "\nError closing ‘%s’: %s\n", argv[argi], strerror(errno)); + fprintf(stderr, "\nxcd: Error closing ‘%s’: %s\n", argv[argi], strerror(errno)); err = 1; goto cleanup; } diff --git a/test-cmd/xcd b/test-cmd/xcd @@ -28,7 +28,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/xcd inputs/chmod_000 + atf_check -s exit:1 -e 'inline:\nxcd: Error opening ‘inputs/chmod_000’: Permission denied\n' -o 'inline:' ../cmd/xcd inputs/chmod_000 } noperm_cleanup() { chmod 0600 inputs/chmod_000 || atf_fail "chmod 0600 chmod_000" @@ -38,9 +38,9 @@ noperm_cleanup() { atf_test_case devfull devfull_body() { # shellcheck disable=SC1112 - atf_check -s 'exit:1' -e 'inline:\nWrite error: No space left on device\n\nError closing ‘inputs/strings/true’: No space left on device\n' sh -c '../cmd/xcd inputs/strings/true >/dev/full' - atf_check -s 'exit:1' -e 'inline:\nWrite error: No space left on device\n' sh -c '../cmd/xcd <inputs/strings/true >/dev/full' - atf_check -s 'exit:1' -e 'inline:\nWrite error: No space left on device\n' sh -c '../cmd/xcd - <inputs/strings/true >/dev/full' + atf_check -s 'exit:1' -e 'inline:\nxcd: Write error: No space left on device\n\nxcd: Error closing ‘inputs/strings/true’: No space left on device\n' sh -c '../cmd/xcd inputs/strings/true >/dev/full' + atf_check -s 'exit:1' -e 'inline:\nxcd: Write error: No space left on device\n' sh -c '../cmd/xcd <inputs/strings/true >/dev/full' + atf_check -s 'exit:1' -e 'inline:\nxcd: Write error: No space left on device\n' sh -c '../cmd/xcd - <inputs/strings/true >/dev/full' } atf_init_test_cases() {