Re: [PATCH] Add a "-h" flag to mv

From: Jilles Tjoelker <jilles_at_stack.nl>
Date: Wed, 29 Aug 2012 21:32:13 +0200
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
Received on Wed Aug 29 2012 - 17:32:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:30 UTC