Hi Jason, Jason McIntyre wrote on Sun, Dec 26, 2010 at 05:39:54PM +0001: > On Sun, Dec 26, 2010 at 06:23:02PM +0100, Ingo Schwarze wrote:
> > > > Index: mv.1 > > =================================================================== > > i have no problem with this diff, but some tweak/concerns below: > > > RCS file: /cvs/src/bin/mv/mv.1,v > > retrieving revision 1.26 > > diff -u -r1.26 mv.1 > > --- mv.1 3 Sep 2010 09:53:20 -0000 1.26 > > +++ mv.1 26 Dec 2010 17:18:08 -0000 > > @@ -38,7 +38,7 @@ > > .Os > > .Sh NAME > > .Nm mv > > -.Nd move files > > +.Nd move files and directories > > hmm... > > cp - copy files > rm - remove directory entries > mv - move files and directories # with your changes > > i'm ok with all approaches, but i fear we are being inconsistent on > three very important utilities about how we describe things. do we > accept that files and directories are the same? do we distinguish? > i think we should make this consistent for all three. I see the point, and i think it is valid. Looking at rm(1), right now, we _do_ consistently assume that files are a special case of directories. Changing that is probably a bad idea, and even if we want to change that stance, it is a separate issue, so i'm pulling that part from the diff. > > .Sh SYNOPSIS > > .Nm mv > > .Op Fl fi > > @@ -49,7 +49,7 @@ > > .Sh DESCRIPTION > > In its first form, the > > .Nm > > -utility moves the file named by the > > +utility moves the file or directory named by the > > .Ar source > > operand to the destination path named by the > > .Ar target > > @@ -59,20 +59,27 @@ > > .Pp > > In its second form, > > .Nm > > -moves each file named by a > > +moves each file and directory named by a > > .Ar source > > -operand to a destination specified by the > > +operand into the destination specified by the > > .Ar directory > > operand. > > It is an error if the > > .Ar directory > > -operand does not exist. > > +does not exist. > > The destination path for each > > .Ar source > > operand is the pathname produced by the concatenation of the > > .Ar directory > > operand, a slash, and the final pathname component of the named file. > > .Pp > > +In both forms, a > > +.Ar source > > +operand is skipped with an error message > > +when the respective destination path is a non-empy directory, > > +or when the source is a file, but the destination path is a directory > > +or vice versa. > > i'd say your comma would be better placed after "directory" and not > "file". Sure. > > +.Pp > > The options are as follows: > > .Bl -tag -width Ds > > .It Fl f > > @@ -117,9 +124,9 @@ > > to accomplish the move. > > The effect is equivalent to: > > .Bd -literal -offset indent > > -$ rm -f destination_path && \e > > - cp -PRp source_file destination && \e > > - rm -rf source_file > > +$ rm -df -- destination_path && \e > > + cp -PRp -- source destination_path && \e > > + rm -rf -- source > > .Ed > > .Sh EXIT STATUS > > .Ex -std mv > > @@ -145,6 +152,26 @@ > > $ mv -i -- -f bar > > $ mv -i ./-f bar > > .Ed > > +.Pp > > +If > > +.Pa f > > +and > > +.Pa g > > +are files and > > +.Pa d > > +and > > +.Pa d/f > > +are directories, the command > > +.Pp > > +.Dl $ mv f g d > > +.Pp > > +will print an error message, leave > > +.Pa f > > +where it is, move > > +.Pa g > > +to > > +.Pa d/g > > +and return a non-zero exit status. > > .Sh SEE ALSO > > .Xr cp 1 , > > .Xr rm 1 , > > @@ -161,20 +188,3 @@ > > .Nm > > command appeared in > > .At v1 . > > -.Sh CAVEATS > > -In the second synopsis form > > -if the destination path exists, > > -the > > -.Ar source > > -operand and the destination path > > -must both be a file or must both be a directory > > -for the operation to succeed. > > -For example, if > > -.Pa f > > -is a file and > > -.Pa d > > -and > > -.Pa d/f > > -are directories, the following command will fail: > > -.Pp > > -.Dl $ mv f d > > i'm not convinced. it feels like you are removing a valid warning, > and turning it into an example. the author obviously intended that > people watch out for this (or had enough experience of people falling > for it, that they saw fit to warn them). you were caught out because > you nearly missed it in CAVEATS - i think it even less likely that > someone would catch it in EXAMPLES. > > so, my instinct is that you "fix" CAVEATS, not move it. i'm happy > to be persuaded otherwise though. Seems valid to. I think moving the description how the utility works to the DESCRIPTION does make sense, but leaving the example in CAVEATS as well. So here is an improved patch: Yours, Ingo Index: mv.1 =================================================================== RCS file: /cvs/src/bin/mv/mv.1,v retrieving revision 1.26 diff -u -r1.26 mv.1 --- mv.1 3 Sep 2010 09:53:20 -0000 1.26 +++ mv.1 26 Dec 2010 18:39:33 -0000 @@ -61,18 +61,25 @@ .Nm moves each file named by a .Ar source -operand to a destination specified by the +operand into the destination specified by the .Ar directory operand. It is an error if the .Ar directory -operand does not exist. +does not exist. The destination path for each .Ar source operand is the pathname produced by the concatenation of the .Ar directory operand, a slash, and the final pathname component of the named file. .Pp +In both forms, a +.Ar source +operand is skipped with an error message +when the respective destination path is a non-empy directory, +or when the source is a non-directory file but the destination path +is a directory, or vice versa. +.Pp The options are as follows: .Bl -tag -width Ds .It Fl f @@ -117,9 +124,9 @@ to accomplish the move. The effect is equivalent to: .Bd -literal -offset indent -$ rm -f destination_path && \e - cp -PRp source_file destination && \e - rm -rf source_file +$ rm -df -- destination_path && \e + cp -PRp -- source destination_path && \e + rm -rf -- source .Ed .Sh EXIT STATUS .Ex -std mv @@ -162,19 +169,27 @@ command appeared in .At v1 . .Sh CAVEATS -In the second synopsis form -if the destination path exists, -the +In the second synopsis form, incompatible file types in .Ar source -operand and the destination path -must both be a file or must both be a directory -for the operation to succeed. +and +.Ar directory +cause partial moves: For example, if .Pa f -is a file and +and +.Pa g +are non-directory files and .Pa d and .Pa d/f -are directories, the following command will fail: +are directories, the command .Pp -.Dl $ mv f d +.Dl $ mv f g d +.Pp +will print an error message, leave +.Pa f +where it is, move +.Pa g +to +.Pa d/g +and return a non-zero exit status.