GNU bug report logs - #69636
Re: [PATCH] Improve quality of format-checking code for seq.

Previous Next

Package: coreutils;

Reported by: 877i7vyf3l.fsf <at> penguin.cs.ucla.edu

Date: Fri, 8 Mar 2024 12:31:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 69636 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#69636; Package coreutils. (Fri, 08 Mar 2024 12:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 877i7vyf3l.fsf <at> penguin.cs.ucla.edu:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 08 Mar 2024 12:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: User <the.f8er <at> gmail.com>
To: eggert <at> cs.ucla.edu
Cc: bug-coreutils <at> gnu.org
Subject: Re: Re: [PATCH] Improve quality of format-checking code for seq.
Date: Fri, 8 Mar 2024 14:29:45 +0200
Jim Meyering <jim <at> meyering.net> wrote:

> Paul Eggert <eggert <at> CS.UCLA.EDU> wrote:
> > * src/seq.c (validate_format): Remove. Migrate its checks into...
> > (long_double_format): Report an error and exit if an error is found,
> > instead of returning NULL.  All callers changed.
> > Use a more-consistent format for diagnostics.
> > * tests/misc/seq: Adjust to the more-consistent format for diagnostics.
> > ---
> >  src/seq.c      |   71 
> +++++++++++++++----------------------------------------
> >  tests/misc/seq |   10 ++++----
> >  2 files changed, 25 insertions(+), 56 deletions(-)
>
> Thanks.
> As far as I can see this is a "no semantic change"
> patch (modulo diagnostics), and it looks fine, so I pushed it.

Dear Paul Eggert and Jim Meyering,


Thank you very much for the contribution and care! I hope you have 
awesome and cozy day!

It is a nice addition to check the format in the most and explicitly 
safe cases, I believe, however it disallows to use it in cases when you 
need to just repeat a character without ANY processing directive! For 
example, `a=10; seq -f 'x' -s '' -- "$a";` would print 10 characters "x" 
without the check added prior and significantly (or little but still) 
support development in long codes which would require explicit loops or 
additional dependencies like awesome Perl.

Is it possible to reconsider the check or add an option to ignore the 
format which does not have a required directive? If you know a better 
alternative to the standard utility which would result in the same small 
code but great result, please suggest if possible!

Again, appreciated, and please stay safe!


Best and kind regards,

Artfaith





Information forwarded to bug-coreutils <at> gnu.org:
bug#69636; Package coreutils. (Fri, 08 Mar 2024 13:50:01 GMT) Full text and rfc822 format available.

Message #8 received at 69636 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: 877i7vyf3l.fsf <at> penguin.cs.ucla.edu, eggert <at> cs.ucla.edu
Cc: 69636 <at> debbugs.gnu.org
Subject: Re: bug#69636: Re: [PATCH] Improve quality of format-checking code
 for seq.
Date: Fri, 8 Mar 2024 13:47:21 +0000
tag 69636 notabug
close 69636
stop

On 08/03/2024 12:29, User wrote:
> 
> Jim Meyering <jim <at> meyering.net> wrote:
> 
>> Paul Eggert <eggert <at> CS.UCLA.EDU> wrote:
>>> * src/seq.c (validate_format): Remove. Migrate its checks into...
>>> (long_double_format): Report an error and exit if an error is found,
>>> instead of returning NULL.  All callers changed.
>>> Use a more-consistent format for diagnostics.
>>> * tests/misc/seq: Adjust to the more-consistent format for diagnostics.
>>> ---
>>>    src/seq.c      |   71
>> +++++++++++++++----------------------------------------
>>>    tests/misc/seq |   10 ++++----
>>>    2 files changed, 25 insertions(+), 56 deletions(-)
>>
>> Thanks.
>> As far as I can see this is a "no semantic change"
>> patch (modulo diagnostics), and it looks fine, so I pushed it.
> 
> Dear Paul Eggert and Jim Meyering,
> 
> 
> Thank you very much for the contribution and care! I hope you have
> awesome and cozy day!
> 
> It is a nice addition to check the format in the most and explicitly
> safe cases, I believe, however it disallows to use it in cases when you
> need to just repeat a character without ANY processing directive! For
> example, `a=10; seq -f 'x' -s '' -- "$a";` would print 10 characters "x"
> without the check added prior and significantly (or little but still)
> support development in long codes which would require explicit loops or
> additional dependencies like awesome Perl.
> 
> Is it possible to reconsider the check or add an option to ignore the
> format which does not have a required directive? If you know a better
> alternative to the standard utility which would result in the same small
> code but great result, please suggest if possible!
> 
> Again, appreciated, and please stay safe!

This suggestion has some merit,
but there are a few ways to generate repetitive data already:

  a=10

  seq $a | xargs printf -- 'x%.0s'

  printf "%${a}s" '' | tr ' ' x

  yes x | head -n$a | tr -d '\n'

Also if only outputting to a terminal, then you can get the
repetition to happen within the terminal code like:

  printf -- "x\e[${a}b"

Therefore I'm not sure it's worth relaxing the validation in seq.

thanks,
Pádraig




Information forwarded to bug-coreutils <at> gnu.org:
bug#69636; Package coreutils. (Fri, 08 Mar 2024 19:15:02 GMT) Full text and rfc822 format available.

Message #11 received at 69636 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>,
 877i7vyf3l.fsf <at> penguin.cs.ucla.edu
Cc: 69636 <at> debbugs.gnu.org
Subject: Re: bug#69636: Re: [PATCH] Improve quality of format-checking code
 for seq.
Date: Fri, 8 Mar 2024 11:14:00 -0800
On 2024-03-08 05:47, Pádraig Brady wrote:

>    seq $a | xargs printf -- 'x%.0s'
> 
>    printf "%${a}s" '' | tr ' ' x
> 
>    yes x | head -n$a | tr -d '\n'

Oh, I like those! Unfortunately the printf solution silently fails for 
me when a=10000000000 due to a bug in Bash. Perhaps I'll get up the 
energy to propose a fix (at least it should *noisily* fail :-).




This bug report was last modified 263 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.