[hackers] [sbase] install: only create parent dirs to dest given -D || Eivind Uggedal
commit b97839751bad4a2b38ed38359ad82153e3e3b9cc
Author: Eivind Uggedal <eivind_AT_uggedal.com>
AuthorDate: Tue Feb 16 22:05:49 2016 +0000
Commit: sin <sin_AT_2f30.org>
CommitDate: Wed Feb 17 08:59:19 2016 +0000
install: only create parent dirs to dest given -D
Given the following commands:
touch 1.txt; install -D 1.txt d/2.txt
find d
The result without this fix:
d
d/2.txt
d/2.txt/1.txt
The result with this patch applied:
d
d/2.txt
diff --git a/xinstall.c b/xinstall.c
index ec96c05..1a6be47 100644
--- a/xinstall.c
+++ b/xinstall.c
_AT_@ -241,11 +241,12 @@ main(int argc, char *argv[])
if (stat(argv[argc - 1], &st) < 0) {
if (errno != ENOENT)
eprintf("stat %s:", argv[argc - 1]);
- if (tflag || argc > 2) {
- p = strrchr(argv[argc - 1], '/');
- *p = '\0';
- make_dirs(argv[argc - 1], 1);
- *p = '/';
+ if (tflag || Dflag || argc > 2) {
+ if ((p = strrchr(argv[argc - 1], '/')) != NULL) {
+ *p = '\0';
+ make_dirs(argv[argc - 1], 1);
+ *p = '/';
+ }
} else {
make_dirs(argv[argc - 1], 1);
}
Received on Wed Feb 17 2016 - 09:59:24 CET
This archive was generated by hypermail 2.3.0
: Wed Feb 17 2016 - 10:00:18 CET