commit: 366aa01f25fbd317b189d3a5b5d707f3f0432d89
parent c1577503387c765fe71fc3450672f6eb2ca1283a
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 20 Sep 2024 05:07:28 +0200
lib/truncate: unify error message formatting
Diffstat:
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/lib/truncation.c b/lib/truncation.c
@@ -26,7 +26,7 @@ apply_truncation(int fd, struct truncation tr, char *arg)
if(fstat(fd, &stats) < 0)
{
fprintf(
- stderr, "truncate: Error: Failed to get status of file '%s': %s\n", arg, strerror(errno));
+ stderr, "truncate: error: Failed to get status of file '%s': %s\n", arg, strerror(errno));
return -1;
}
@@ -58,7 +58,7 @@ apply_truncation(int fd, struct truncation tr, char *arg)
if(ftruncate(fd, tr.size) < 0)
{
fprintf(stderr,
- "truncate: Error: Failed to truncate '%s' to %ld: %s\n",
+ "truncate: error: Failed to truncate '%s' to %ld: %s\n",
arg,
tr.size,
strerror(errno));
@@ -86,7 +86,7 @@ apply_size_suffix(unsigned long *size, char *endptr)
}
if(i >= sizeof(units) || si == 1)
{
- fprintf(stderr, "%s: Unrecognised unit '%s'\n", argv0, endptr);
+ fprintf(stderr, "%s: error: Unrecognised unit '%s'\n", argv0, endptr);
return -1;
}
@@ -101,7 +101,7 @@ apply_size_suffix(unsigned long *size, char *endptr)
return 0;
}
- fprintf(stderr, "%s: Unrecognised suffix '%s'\n", argv0, endptr);
+ fprintf(stderr, "%s: error: Unrecognised suffix '%s'\n", argv0, endptr);
return -1;
}
@@ -113,7 +113,7 @@ parse_size(const char *arg, struct truncation *buf)
if(arg[0] == 0)
{
- fprintf(stderr, "%s: Got empty size argument\n", argv0);
+ fprintf(stderr, "%s: error: Got empty size argument\n", argv0);
buf->size = 0;
return -1;
}
@@ -146,7 +146,8 @@ parse_size(const char *arg, struct truncation *buf)
unsigned long size = strtoul(arg, &endptr, 10);
if(errno != 0)
{
- fprintf(stderr, "%s: Failed parsing '%s' as a number: %s\n", argv0, arg, strerror(errno));
+ fprintf(
+ stderr, "%s: error: Failed parsing '%s' as a number: %s\n", argv0, arg, strerror(errno));
return -1;
}
diff --git a/test-cmd/head.sh b/test-cmd/head.sh
@@ -49,6 +49,6 @@ t_cmd 40c '40960
' head_40kc
head_40d() { </dev/zero "$target" -c 40d | wc -c | awk '{ print $1 }'; }
-t_cmd --exit=1 40d "head: Unrecognised unit 'd'
+t_cmd --exit=1 40d "head: error: Unrecognised unit 'd'
0
" head_40d