bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Pádraig Brady
Subject: bug#69636: Re: [PATCH] Improve quality of format-checking code for seq.
Date: Fri, 8 Mar 2024 13:47:21 +0000
User-agent: Mozilla Thunderbird

tag 69636 notabug
close 69636
stop

On 08/03/2024 12:29, User wrote:

Jim Meyering <jim@meyering.net> wrote:

Paul Eggert <eggert@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]