/bin/rmdir: Exit with status 2 for invalid arguments

PR: 277677

Signed-off-by: Henrich Hartzer <henrichhartzer@tuta.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1161
This commit is contained in:
Henrich Hartzer 2024-05-10 17:53:49 +00:00 committed by Warner Losh
parent 3d966ae789
commit 9bcc1b18c1
3 changed files with 12 additions and 11 deletions

View File

@ -74,14 +74,14 @@ The
.Nm .Nm
utility exits with one of the following values: utility exits with one of the following values:
.Bl -tag -width indent .Bl -tag -width indent
.It Li 0 .It Er 0
Each directory entry specified by a Each
.Ar directory .Ar directory
operand referred to an empty directory and was removed successfully.
referred to an empty directory and was removed .It Er 1
successfully. An error occurred while attempting to remove one or more directories.
.It Li >0 .It Er 2
An error occurred. Invalid arguments.
.El .El
.Sh EXAMPLES .Sh EXAMPLES
Remove the directory Remove the directory
@ -97,6 +97,7 @@ stopping at the first non-empty directory (if any):
.Dl $ rmdir -p cow/horse/monkey .Dl $ rmdir -p cow/horse/monkey
.Sh SEE ALSO .Sh SEE ALSO
.Xr rm 1 .Xr rm 1
.Xr rmdir 2
.Sh STANDARDS .Sh STANDARDS
The The
.Nm .Nm

View File

@ -112,5 +112,5 @@ usage(void)
{ {
(void)fprintf(stderr, "usage: rmdir [-pv] directory ...\n"); (void)fprintf(stderr, "usage: rmdir [-pv] directory ...\n");
exit(1); exit(2);
} }

View File

@ -35,8 +35,8 @@ invalid_usage_head()
invalid_usage_body() invalid_usage_body()
{ {
atf_check -s not-exit:0 -e match:"$usage_output" rmdir -p atf_check -s exit:2 -e match:"$usage_output" rmdir -p
atf_check -s not-exit:0 -e match:"$usage_output" rmdir -v atf_check -s exit:2 -e match:"$usage_output" rmdir -v
} }
atf_test_case no_arguments atf_test_case no_arguments
@ -47,7 +47,7 @@ no_arguments_head()
no_arguments_body() no_arguments_body()
{ {
atf_check -s not-exit:0 -e match:"$usage_output" rmdir atf_check -s exit:2 -e match:"$usage_output" rmdir
} }
atf_init_test_cases() atf_init_test_cases()