[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: busybox seq doesn't handle negative numbers
From:       Keith Thompson <Keith.S.Thompson () gmail ! com>
Date:       2023-04-11 20:11:57
Message-ID: CAAHpriOErPgaDncSawZ8_wUHeja+PuEGm+ptXimz3M0EBvjpkg () mail ! gmail ! com
[Download RAW message or body]

On Tue, Apr 11, 2023 at 11:31 AM Denys Vlasenko
<vda.linux@googlemail.com> wrote:
>
> On Mon, Apr 10, 2023 at 6:34 PM Keith Thompson
> <Keith.S.Thompson@gmail.com> wrote:
> > On Mon, Apr 10, 2023 at 5:35 AM Denys Vlasenko <vda.linux@googlemail.com> wrote:
> > > On Tue, Apr 4, 2023 at 7:16 AM Keith Thompson
> > > <Keith.S.Thompson@gmail.com> wrote:
> > > > The GNU coreutils seq command recognizes and handles negative
> > > > arguments.
> > > >
> > > > The busybox seq command does not. Any argument starting with a '-'
> > > > character is assumed to be an option name.
> > >
> > >
> > > Fixed, please try current git.
> >
> > I just tried it (commit 200a9669f), and there's still a bug.
> >
> > If you use "-s" with an argument *and* a negative number, it prints a
> > usage message.
> > $ busybox seq -s : -1 1
> > seq: invalid option -- '1'
>
> Fixed this too, please try current git.

The current version (commit 478b5ac2b, 2023-04-11) correctly handles
all the test cases from my previous email.

I see from the comments that it can still break on "-s -1" (it hadn't
even occurred to me that the separator can be more than one character),
but that's probably not worth worrying about. Other separators starting
with "-" do work, including "-s --".

    $ busybox seq -s - -1 1
    -1-0-1
    $ busybox seq -s -- -1 1
    -1--0--1
    $ seq -s -1 -1 1
    seq: option requires an argument -- 's'
    [snip]

I have some vague thoughts about ways to handle the arguments that
correctly handle a few more corner cases, but I'm not going to worry
about it too much.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic