From 27ebf0630af26a85a667b724d2ea986f6868b749 Mon Sep 17 00:00:00 2001 From: brooks Date: Tue, 22 Jan 2013 16:23:08 +0000 Subject: Make "install -l s[ar]" act like "ln -sfh" as intended. This fixes installation of symbolic links where the target is a link is to an existing directory. --- usr.bin/xinstall/xinstall.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'usr.bin/xinstall') diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 101b487..a173873 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -336,8 +336,21 @@ main(int argc, char *argv[]) /* NOTREACHED */ } - no_target = stat(to_name = argv[argc - 1], &to_sb); + to_name = argv[argc - 1]; + no_target = stat(to_name, &to_sb); if (!no_target && S_ISDIR(to_sb.st_mode)) { + if (dolink & LN_SYMBOLIC) { + if (lstat(to_name, &to_sb) != 0) + err(EX_OSERR, "%s vanished", to_name); + if (S_ISLNK(to_sb.st_mode)) { + if (argc != 2) { + errno = ENOTDIR; + err(EX_USAGE, "%s", to_name); + } + install(*argv, to_name, fset, iflags); + exit(EX_OK); + } + } for (; *argv != to_name; ++argv) install(*argv, to_name, fset, iflags | DIRECTORY); exit(EX_OK); -- cgit v1.1