Todd C. Miller <[email protected]> wrote:

> On Thu, 02 Jun 2022 14:36:16 +0200, Jan Stary wrote:
> 
> > That results in the above. What obsolete options format
> > is this trying to accomodate? The manpage doesn't say -
> > the options it describes are perfectly getopt()-likable.
> > Looking at the CVS log, this was already "obsolete"
> > in the original 1995 import. Does anyone still use
> > that undescribed obsolete syntax dump "supports"?
> 
> Yes, many people do, myself included.  These programs have worked
> this way for the past 42 years and you cannot just break that.
> 
> However, it may be reasonable to skip parsing in obsolete() if the
> first argument contains a '/' since that is cannot match the old
> syntax.  FreeBSD just checks for a leading slash.

Hmm, but consider these cases

dump home

or

mkdir 0af
dump 0af

or

cd /dev && dump rsd0a

Don't people always pass at least '0' (to ignore a stored level) and/or
'a' (to avoid the volume sizing code), on very large filesystems in
particular, so it becomes good practice to always pass at least one
option, so maybe we should just state the requirement is you must pass a
flag?  Or are there people passing no flags?

>  - todd
> 
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/sbin/dump/main.c,v
> retrieving revision 1.62
> diff -u -p -u -r1.62 main.c
> --- main.c    21 Jan 2021 00:16:36 -0000      1.62
> +++ main.c    2 Jun 2022 13:32:15 -0000
> @@ -718,9 +718,9 @@ obsolete(int *argcp, char **argvp[])
>       argv = *argvp;
>       argc = *argcp;
>  
> -     /* Return if no arguments or first argument has leading dash. */
> +     /* Return if no args or first argument has leading dash or a slash. */
>       ap = argv[1];
> -     if (argc == 1 || *ap == '-')
> +     if (argc == 1 || *ap == '-' || strchr(ap, '/') != NULL)
>               return;
>  
>       /* Allocate space for new arguments. */
> 

Reply via email to