=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/xinstall/xinstall.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- src/usr.bin/xinstall/xinstall.c 2015/04/18 03:15:46 1.59 +++ src/usr.bin/xinstall/xinstall.c 2015/07/18 14:32:36 1.60 @@ -1,4 +1,4 @@ -/* $OpenBSD: xinstall.c,v 1.59 2015/04/18 03:15:46 guenther Exp $ */ +/* $OpenBSD: xinstall.c,v 1.60 2015/07/18 14:32:36 jasper Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* @@ -49,6 +49,7 @@ #include #include #include +#include #include "pathnames.h" @@ -61,7 +62,7 @@ struct passwd *pp; struct group *gp; -int dobackup, docompare, dodir, dopreserve, dostrip, safecopy; +int dobackup, docompare, dodest, dodir, dopreserve, dostrip, safecopy; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; char pathbuf[PATH_MAX], tempfile[PATH_MAX]; char *suffix = BACKUP_SUFFIX; @@ -90,7 +91,7 @@ char *flags, *to_name, *group = NULL, *owner = NULL; iflags = 0; - while ((ch = getopt(argc, argv, "B:bCcdf:g:m:o:pSs")) != -1) + while ((ch = getopt(argc, argv, "B:bCcDdf:g:m:o:pSs")) != -1) switch(ch) { case 'C': docompare = 1; @@ -131,6 +132,9 @@ case 's': dostrip = 1; break; + case 'D': + dodest = 1; + break; case 'd': dodir = 1; break; @@ -168,6 +172,13 @@ /* NOTREACHED */ } + if (dodest) { + char *dest = dirname(argv[argc - 1]); + if (dest == NULL) + errx(EX_OSERR, "cannot determine dirname"); + install_dir(dest); + } + no_target = stat(to_name = argv[argc - 1], &to_sb); if (!no_target && S_ISDIR(to_sb.st_mode)) { for (; *argv != to_name; ++argv) @@ -603,7 +614,7 @@ usage(void) { (void)fprintf(stderr, "\ -usage: install [-bCcdpSs] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner]\n source ... target ...\n"); +usage: install [-bCcDdpSs] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner]\n source ... target ...\n"); exit(EX_USAGE); /* NOTREACHED */ }