dirname: support multiple arguments.

This commit is contained in:
Elliott Hughes 2018-11-13 14:17:33 -08:00 committed by Rob Landley
parent 2559f9dd6b
commit d1d751e4be
2 changed files with 5 additions and 2 deletions

View File

@ -8,3 +8,4 @@ testing "/-only" "dirname ///////" "/\n" "" ""
testing "trailing /" "dirname a//////" ".\n" "" ""
testing "combined" "dirname /////a///b///c///d/////" "/////a///b///c\n" "" ""
testing "/a/" "dirname /////a///" "/\n" "" ""
testing "multiple" "dirname hello/a world/b" "hello\nworld\n" "" ""

View File

@ -10,7 +10,7 @@ config DIRNAME
bool "dirname"
default y
help
usage: dirname PATH
usage: dirname PATH...
Show directory portion of path.
*/
@ -19,5 +19,7 @@ config DIRNAME
void dirname_main(void)
{
puts(dirname(*toys.optargs));
char **arg;
for (arg = toys.optargs; *arg; ++arg) puts(dirname(*arg));
}