GNU bug report logs -
#69636
Re: [PATCH] Improve quality of format-checking code for seq.
Previous Next
Reported by: 877i7vyf3l.fsf <at> penguin.cs.ucla.edu
Date: Fri, 8 Mar 2024 12:31:02 UTC
Severity: normal
Tags: notabug, patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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
This bug report was last modified 99 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.