Add -R alias to -r for scp(1)

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Add -R alias to -r for scp(1)

Kurt Mosiejczuk-9
cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R as an
alias for -r to scp(1) for those assuming consistency with cp(1).

--Kurt

Index: scp.1
===================================================================
RCS file: /cvs/src/usr.bin/ssh/scp.1,v
retrieving revision 1.87
diff -u -p -r1.87 scp.1
--- scp.1 30 Nov 2019 07:07:59 -0000 1.87
+++ scp.1 2 Jan 2020 01:08:01 -0000
@@ -215,6 +215,12 @@ Recursively copy entire directories.
 Note that
 .Nm
 follows symbolic links encountered in the tree traversal.
+.It Fl R
+A synonym for
+.Fl r .
+(To mimic the
+.Xr cp 1
+flag for recursive copy).
 .It Fl S Ar program
 Name of
 .Ar program
Index: scp.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/scp.c,v
retrieving revision 1.206
diff -u -p -r1.206 scp.c
--- scp.c 9 Sep 2019 02:31:19 -0000 1.206
+++ scp.c 2 Jan 2020 01:08:01 -0000
@@ -404,7 +404,7 @@ main(int argc, char **argv)
 
  fflag = Tflag = tflag = 0;
  while ((ch = getopt(argc, argv,
-    "dfl:prtTvBCc:i:P:q12346S:o:F:J:")) != -1) {
+    "dfl:pRrtTvBCc:i:P:q12346S:o:F:J:")) != -1) {
  switch (ch) {
  /* User-visible flags. */
  case '1':
@@ -452,6 +452,7 @@ main(int argc, char **argv)
  case 'p':
  pflag = 1;
  break;
+ case 'R':
  case 'r':
  iamrecursive = 1;
  break;

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Ted Unangst-6
Kurt Mosiejczuk wrote:
> cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R as an
> alias for -r to scp(1) for those assuming consistency with cp(1).

But it doesn't implement cp -R semantics. It does the copy the way cp -r does.
(For symlinks, etc.)

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Kurt Mosiejczuk-9
On Wed, Jan 01, 2020 at 09:15:14PM -0500, Ted Unangst wrote:
> Kurt Mosiejczuk wrote:
> > cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R as an
> > alias for -r to scp(1) for those assuming consistency with cp(1).

> But it doesn't implement cp -R semantics. It does the copy the way cp -r does.
> (For symlinks, etc.)

According to cp(1), there *isn't* a -r. That's the whole reason I found it
odd we use the opposite flag for scp(1).

--Kurt

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Kurt Mosiejczuk-9
On Wed, Jan 01, 2020 at 09:31:29PM -0500, Kurt Mosiejczuk wrote:
> On Wed, Jan 01, 2020 at 09:15:14PM -0500, Ted Unangst wrote:
> > Kurt Mosiejczuk wrote:
> > > cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R as an
> > > alias for -r to scp(1) for those assuming consistency with cp(1).

> > But it doesn't implement cp -R semantics. It does the copy the way cp -r does.
> > (For symlinks, etc.)

> According to cp(1), there *isn't* a -r. That's the whole reason I found it
> odd we use the opposite flag for scp(1).

I see, I had to be grubbing around in the STANDARDS section of the man
page to know it exists. It also says I shouldn't use it.

--Kurt

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Ingo Schwarze
In reply to this post by Kurt Mosiejczuk-9
Hi Kurt,

Kurt Mosiejczuk wrote on Wed, Jan 01, 2020 at 08:21:04PM -0500:

> cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R
> as an alias for -r to scp(1) for those assuming consistency with cp(1).

even if cp -R and scp -r did the same thing - which, if i understand
tedu@ correctly, is not the case - i would still dislike introducing
an alias.

Aliases make documentation longer for no benefit and sometimes
also cause confusion.  They also block namespace for no benefit
(or rather, option space in this case).

While it is nice when different commands can use the same options
for similar purposes, that is not always possible.  And even when
it would have been possible when designing the tools in the past,
if a different decision was made back then, remaining consistent
with previous versions of the same command is usually worth more
than symmetry with a different command.

Sometimes, aliases are needed because different other operating
systems use different names and we want to be compatible with both.
But whenever they can be avoided, they should.

When working on documentation, i'm actively trying to deprecate
aliases where that is possible.

Yours,
  Ingo


> Index: scp.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/ssh/scp.1,v
> retrieving revision 1.87
> diff -u -p -r1.87 scp.1
> --- scp.1 30 Nov 2019 07:07:59 -0000 1.87
> +++ scp.1 2 Jan 2020 01:08:01 -0000
> @@ -215,6 +215,12 @@ Recursively copy entire directories.
>  Note that
>  .Nm
>  follows symbolic links encountered in the tree traversal.
> +.It Fl R
> +A synonym for
> +.Fl r .
> +(To mimic the
> +.Xr cp 1
> +flag for recursive copy).
>  .It Fl S Ar program
>  Name of
>  .Ar program
> Index: scp.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/ssh/scp.c,v
> retrieving revision 1.206
> diff -u -p -r1.206 scp.c
> --- scp.c 9 Sep 2019 02:31:19 -0000 1.206
> +++ scp.c 2 Jan 2020 01:08:01 -0000
> @@ -404,7 +404,7 @@ main(int argc, char **argv)
>  
>   fflag = Tflag = tflag = 0;
>   while ((ch = getopt(argc, argv,
> -    "dfl:prtTvBCc:i:P:q12346S:o:F:J:")) != -1) {
> +    "dfl:pRrtTvBCc:i:P:q12346S:o:F:J:")) != -1) {
>   switch (ch) {
>   /* User-visible flags. */
>   case '1':
> @@ -452,6 +452,7 @@ main(int argc, char **argv)
>   case 'p':
>   pflag = 1;
>   break;
> + case 'R':
>   case 'r':
>   iamrecursive = 1;
>   break;

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Marc Espie-2
On Thu, Jan 02, 2020 at 11:19:30AM +0100, Ingo Schwarze wrote:

> Hi Kurt,
>
> Kurt Mosiejczuk wrote on Wed, Jan 01, 2020 at 08:21:04PM -0500:
>
> > cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R
> > as an alias for -r to scp(1) for those assuming consistency with cp(1).
>
> even if cp -R and scp -r did the same thing - which, if i understand
> tedu@ correctly, is not the case - i would still dislike introducing
> an alias.
>
> Aliases make documentation longer for no benefit and sometimes
> also cause confusion.  They also block namespace for no benefit
> (or rather, option space in this case).
>
> While it is nice when different commands can use the same options
> for similar purposes, that is not always possible.  And even when
> it would have been possible when designing the tools in the past,
> if a different decision was made back then, remaining consistent
> with previous versions of the same command is usually worth more
> than symmetry with a different command.
>
> Sometimes, aliases are needed because different other operating
> systems use different names and we want to be compatible with both.
> But whenever they can be avoided, they should.
>
> When working on documentation, i'm actively trying to deprecate
> aliases where that is possible.
>
> Yours,
>   Ingo

Contrary point: I'm with Kurt on that one.  Very often, I do mix up -r
and -R, and I do hate it.  Especially since our cp *does* have a -r which is
subtly different.

Not having -R in scp means you can do all kinds of fuckups.

Once in three times, I type scp -R and go "oh fuck" when it doesn't work.

And if I use scp enough, I'm also likely to use cp -r  by mistake.

Are we likely to actually remove cp -r so the second mistake
doesn't happen ?

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Ingo Schwarze
Hi Marc,

Marc Espie wrote on Thu, Jan 02, 2020 at 11:30:35AM +0100:

> And if I use scp enough, I'm also likely to use cp -r  by mistake.
>
> Are we likely to actually remove cp -r so the second mistake
> doesn't happen ?

I wouldn't be opposed to that.  It has been deprecated since
rev. 1.1 in 1995.  FreeBSD also deprecates it but has subtly
different behaviour.  NetBSD has the same deprecation notice
we have.  In GNU cp(1), according to the manual, it seems to be
an alias for cp -R.  Illumos and Oracle Solaris seem to somewhat
resemble FreeBSD - not sure all is identical - but -r is not
deprecated.

Given these differences, it seems doubtful how much sense it makes
to keep it "for compatibility".

However, deleting it would require a full make build and a ports
bulk build, i guess.


If it turns out it sees substantial use in the wild, i think we
should make cp -r a deprecated alias for cp -R because i expect
that almost every software out there using it (if any) probably
comes from the Linux world, given that is has been deprecated in
all BSDs for more than two decades.

Yours,
  Ingo

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Theo de Raadt-2
In reply to this post by Kurt Mosiejczuk-9
>Kurt Mosiejczuk wrote:
>> cp(1) uses -R for recursive copy. scp(1) uses -r. This diff adds -R as an
>> alias for -r to scp(1) for those assuming consistency with cp(1).
>
>But it doesn't implement cp -R semantics. It does the copy the way cp -r does.
>(For symlinks, etc.)

very good point.  the subtle difference says no.

Reply | Threaded
Open this post in threaded view
|

Re: Add -R alias to -r for scp(1)

Jan Stary
In reply to this post by Marc Espie-2
On Jan 02 11:30:35, [hidden email] wrote:
> Once in three times, I type scp -R and go "oh fuck" when it doesn't work.

Same here with 'ssh -p' vs 'scp -P'.