From owner-freebsd-current@FreeBSD.ORG Wed Aug 29 19:32:14 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D0E14106566B; Wed, 29 Aug 2012 19:32:14 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 6940D8FC17; Wed, 29 Aug 2012 19:32:14 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 98B663592E1; Wed, 29 Aug 2012 21:32:13 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 753332847B; Wed, 29 Aug 2012 21:32:13 +0200 (CEST) Date: Wed, 29 Aug 2012 21:32:13 +0200 From: Jilles Tjoelker To: John Baldwin Message-ID: <20120829193213.GA70385@stack.nl> References: <201208281058.10029.jhb@freebsd.org> <20120829100247.GA66677@stack.nl> <201208290809.20455.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201208290809.20455.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: current@freebsd.org Subject: Re: [PATCH] Add a "-h" flag to mv X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2012 19:32:14 -0000 On Wed, Aug 29, 2012 at 08:09:20AM -0400, John Baldwin wrote: > On Wednesday, August 29, 2012 6:02:47 am Jilles Tjoelker wrote: > > GNU coreutils mv (and also cp/install/ln) appears to use > > -T/--no-target-directory for a similar purpose: -T prevents the target > > being treated as a directory (whether it is a symlink or not). > Hmm, I could find no documentation for this online via Google searches or > the Linux manpages we have on www.FreeBSD.org. Bah, Google just makes > searching for these sorts of things painful it seems (you have to put > explicit quotes around "--no-target-directory" for it to actually be used). > Also, it seems I just chose all the wrong Linux manpage sets to look at. > It seems that Linux's -T flag is similar to -h for ln as well. I don't think > we can deprecate -h for ln, but perhaps we could add -T as a compat flag to > ln and mv? I'd be inclined to still add -h to mv so that it mirrors ln. > Hmm, it seems RedHat's ln uses -n for this (OpenBSD, NetBSD, and Darwin > all include a -n as an alias to -h for ln to support compat with other > operating systems). OSF/1 (and Tru64) and SunOS use -n to mean "complain > if the file already exists" similar to 'mv -n'. Also, looking at the > Suse manpage on www.FreeBSD.org, it seems their ln (which does have -T) > has both -n and -T with different descriptions, but to achieve the same > purpose: > http://www.freebsd.org/cgi/man.cgi?query=ln&apropos=0&sektion=0&manpath=SuSE+Linux%2Fi386+11.3&arch=default&format=html > -n, --no-dereference > treat destination that is a symlink to a directory as if it were > a normal file > -T, --no-target-directory > treat LINK_NAME as a normal file > (To me it seems LINK_NAME and destination are the same thing.) > My inclination would be to add -h to mv, but perhaps add -T as an alias > for -h to both ln and mv, and -n as an alias for -h to ln (if we want > aliases to match coreutils). Coreutils ln -n is the same as our ln -h, and we already have compatibility for it. The coreutils -T option is different, though. It forces the ln source_file target_file synopsis instead of the ln source_file ... target_dir synopsis, without checking the type of the final operand. If there are not exactly two operands, a syntax error occurs. If the final operand is a directory and cannot be overwritten, an error occurs. -- Jilles Tjoelker