Discussion:
[Toybox] [PATCH] dirname: support multiple arguments.
enh
2018-11-13 22:19:11 UTC
Permalink
---
tests/dirname.test | 1 +
toys/posix/dirname.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/dirname.test b/tests/dirname.test
index 3ea8919..47b26e0 100755
--- a/tests/dirname.test
+++ b/tests/dirname.test
@@ -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" "" ""
diff --git a/toys/posix/dirname.c b/toys/posix/dirname.c
index 06470ad..fa84af2 100644
--- a/toys/posix/dirname.c
+++ b/toys/posix/dirname.c
@@ -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));
}
--
2.19.1.930.g4563a0d9d0-goog
enh
2018-11-14 19:18:14 UTC
Permalink
early ping because i'm sure whether this one arrived just too late to
be committed when the others were (it was the last), or whether
dirname/basename were sufficiently similar that you think you've
already committed this one too :-)
Post by enh
---
tests/dirname.test | 1 +
toys/posix/dirname.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/dirname.test b/tests/dirname.test
index 3ea8919..47b26e0 100755
--- a/tests/dirname.test
+++ b/tests/dirname.test
@@ -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" "" ""
diff --git a/toys/posix/dirname.c b/toys/posix/dirname.c
index 06470ad..fa84af2 100644
--- a/toys/posix/dirname.c
+++ b/toys/posix/dirname.c
@@ -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));
}
--
2.19.1.930.g4563a0d9d0-goog
Rob Landley
2018-11-17 20:41:11 UTC
Permalink
Post by enh
---
tests/dirname.test | 1 +
toys/posix/dirname.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
Gmail is now putting every single email from you in the spam folder, and does
not learn from me fishing them back out again.

I think this qualifies as irony.

Rob

Continue reading on narkive:
Loading...