diff options
-rwxr-xr-x | tests/install.test | 4 | ||||
-rw-r--r-- | toys/posix/cp.c | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/tests/install.test b/tests/install.test index 228d2470..b1113c0f 100755 --- a/tests/install.test +++ b/tests/install.test @@ -13,3 +13,7 @@ testing "install -D exists" \ "mkdir -p a; touch a/b; install -D random a/b && cmp random a/b && echo yes" \ "yes\n" "" "" rm -rf a random +testing "install -D -t creates directory" \ + "touch a; install -Dt b a && echo yes" \ + "yes\n" "" "" +rm -rf a b diff --git a/toys/posix/cp.c b/toys/posix/cp.c index d98c2ae7..a27c200a 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -520,11 +520,11 @@ void install_main(void) return; } - if (FLAG(D) && !FLAG(t)) { - TT.destname = toys.optargs[toys.optc-1]; - if (mkpathat(AT_FDCWD, TT.destname, 0, MKPATHAT_MAKE)) - perror_exit("-D '%s'", TT.destname); - if (toys.optc == 1) return; + if (FLAG(D)) { + char *destname = FLAG(t) ? TT.i.t : (TT.destname = toys.optargs[toys.optc-1]); + if (mkpathat(AT_FDCWD, destname, 0777, MKPATHAT_MAKE | (FLAG(t) ? MKPATHAT_MKLAST : 0))) + perror_exit("-D '%s'", destname); + if (toys.optc == !FLAG(t)) return; } // Translate flags from install to cp |