logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git
commit: 67b622fb99a712af1c65a5c1900ec365cfe4841a
parent 9f69b242880475285c28b1d85bf0c8088073e0db
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri, 20 Sep 2024 03:57:24 +0200

cmd/rmdir: unify error message formatting

Diffstat:

Mcmd/rmdir.c10+++++-----
Mtest-cmd/rmdir.t10+++++-----
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/cmd/rmdir.c b/cmd/rmdir.c @@ -62,11 +62,11 @@ main(int argc, char *argv[]) verbose = true; break; case ':': - fprintf(stderr, "rmdir: Error: Missing operand for option: '-%c'\n", optopt); + fprintf(stderr, "rmdir: error: Missing operand for option: '-%c'\n", optopt); usage(); return 1; case '?': - fprintf(stderr, "rmdir: Error: Unrecognised option: '-%c'\n", optopt); + fprintf(stderr, "rmdir: error: Unrecognised option: '-%c'\n", optopt); usage(); return 1; default: @@ -79,7 +79,7 @@ main(int argc, char *argv[]) if(argc == 0) { - fprintf(stderr, "rmdir: missing operand\n"); + fprintf(stderr, "rmdir: error: missing operand\n"); usage(); return 1; } @@ -95,7 +95,7 @@ main(int argc, char *argv[]) { if(ign_enotempty && (errno == ENOTEMPTY || errno == EEXIST)) continue; - fprintf(stderr, "rmdir: Failed removing '%s': %s\n", path, strerror(errno)); + fprintf(stderr, "rmdir: error: Failed removing '%s': %s\n", path, strerror(errno)); err = 1; continue; } @@ -118,7 +118,7 @@ main(int argc, char *argv[]) if(errno == ENOTDIR) break; if(ign_enotempty && (errno == ENOTEMPTY || errno == EEXIST)) break; - fprintf(stderr, "rmdir: Failed removing '%s': %s\n", path, strerror(errno)); + fprintf(stderr, "rmdir: error: Failed removing '%s': %s\n", path, strerror(errno)); err = 1; break; } diff --git a/test-cmd/rmdir.t b/test-cmd/rmdir.t @@ -29,22 +29,22 @@ $ touch file $ rmdir file - rmdir: Failed removing 'file': Not a directory + rmdir: error: Failed removing 'file': Not a directory [1] $ rmdir -p file - rmdir: Failed removing 'file': Not a directory + rmdir: error: Failed removing 'file': Not a directory [1] $ rmdir -v file - rmdir: Failed removing 'file': Not a directory + rmdir: error: Failed removing 'file': Not a directory [1] $ rmdir -pv file - rmdir: Failed removing 'file': Not a directory + rmdir: error: Failed removing 'file': Not a directory [1] $ rm file $ mkdir -p e_not_empty/a/b/c/d empty/a/b/c $ rmdir -p e_not_empty/a/b/c empty/a/b/c - rmdir: Failed removing 'e_not_empty/a/b/c': Directory not empty + rmdir: error: Failed removing 'e_not_empty/a/b/c': Directory not empty [1] $ test -d e_not_empty/a/b/c $ test ! -e empty