"-v" handling in scp (was Re: add scp path to _PATH_STDPATH)

mouring at etoh.eviladmin.org mouring at etoh.eviladmin.org
Mon Mar 5 10:07:55 EST 2001


>                 case 'v':
> !                 verbose_mode ++; /* for remote  */
> !                 if(verbose_mode <= 3)
> !                   addargs("-v"); /* for local ssh */
> !                 if(verbose_mode == 4)
> !                   {
> !
> !                     fprintf(stderr,"\nOnly the first three '-v's are
> honoured for passing to remote scp. \n");
> !                     fprintf(stderr,"OpenSSH ssh 2.5.1p2 only accepts only
> up to three '-v's.\n");
> !                     fprintf(stderr,"The rest is ignored.\n\n");
> !
> !                   }
> !                 break;

Why?  It's much better just outright fail. 


>                 case 'q':
>                         showprogress = 0;
>                         break;
> ***************
> *** 330,336 ****
>         remin = remout = -1;
>         /* Command to be executed on remote system using "ssh". */
>         (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
> !           verbose_mode ? " -v" : "",
>             iamrecursive ? " -r" : "", pflag ? " -p" : "",
>             targetshouldbedirectory ? " -d" : "");
> 
> --- 340,350 ----
>         remin = remout = -1;
>         /* Command to be executed on remote system using "ssh". */
>         (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
> !                       /** try to handle up to three '-v's. */
> !                       verbose_mode <=0  ? ""
> !                       : ( verbose_mode == 1 ? " -v"
> !                           : ( verbose_mode == 2 ? " -v -v"
> !                               : " -v -v -v" )),

I'd rather see:

/* Macro to handle verbosity of scp */
#define	print_verbose(count)\
		(count == 0  ? "" 
			: ( count == 1 ? " -v"
				: ( count == 2 ? " -v -v"
					: " -v -v -v" )))

And then reuse the 'print_verbose()' macro.  Incase some day we
wish to support more or less verboseness.

Unsure, what Markus' view are.

- Ben






More information about the openssh-unix-dev mailing list