mirror of git://git.suckless.org/sbase
install: Fix -d with more than two directories
The `tflag || argc > 2` if-statement should only apply when not creating directories (-d). Otherwise, if we are creating more than two directories, we get an error if the last argument does not already exist. To fix this, move the -d case above and return early.
This commit is contained in:
parent
f3d05ffd0a
commit
5c63ffad33
12
xinstall.c
12
xinstall.c
|
@ -198,6 +198,12 @@ main(int argc, char *argv[])
|
||||||
if (mflag)
|
if (mflag)
|
||||||
mode = parsemode(mflag, mode, 0);
|
mode = parsemode(mflag, mode, 0);
|
||||||
|
|
||||||
|
if (dflag) {
|
||||||
|
for (; *argv; argc--, argv++)
|
||||||
|
make_dirs(*argv, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (tflag) {
|
if (tflag) {
|
||||||
argv = memmove(argv - 1, argv, argc * sizeof(*argv));
|
argv = memmove(argv - 1, argv, argc * sizeof(*argv));
|
||||||
argv[argc++] = tflag;
|
argv[argc++] = tflag;
|
||||||
|
@ -213,11 +219,6 @@ main(int argc, char *argv[])
|
||||||
eprintf("%s: not a directory\n", argv[argc - 1]);
|
eprintf("%s: not a directory\n", argv[argc - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dflag) {
|
|
||||||
for (; *argv; argc--, argv++)
|
|
||||||
make_dirs(*argv, 0);
|
|
||||||
} else {
|
|
||||||
if (stat(argv[argc - 1], &st) < 0) {
|
if (stat(argv[argc - 1], &st) < 0) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
eprintf("stat %s:", argv[argc - 1]);
|
eprintf("stat %s:", argv[argc - 1]);
|
||||||
|
@ -230,7 +231,6 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enmasse(argc, argv, install);
|
enmasse(argc, argv, install);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue