On 20/09/2025 at 14:03, Stan Marsh wrote:
Very entertaining thread! Blast from the past!
Regarding the fundamental question of "Is this a bug or not?", note that
in computer stuff, yeah, most people's intuitive idea of what "repeat n
times" means is "Do it n times". And most implementations I've seen of
a "repeat" keyword in programming have meant that. Didn't Pascal have a
"repeat" command?
Yet, when I asked a friend the question: If I asked you to repeat
something 5 times, how many times would you end up doing it?", she
replied without any pause "6 times".
And think about the simplest case: If I asked you to repeat something,
you'd probably assume that meant to do it exactly twice.
Anyway, comments on the code. It looks like the original author (of
both "repeat" and "seq") went to great lengths to make it do that. The
"seq" function is specifically coded to do it one more time than you'd
normally expect. So, the simplest fix/patch to the code would be to
simply remove the final "echo" from the "seq" function.
On my machines (Slack 15 / LMDE 6) 'seq 100' prints a line 100 times.
seq is an elf binary, not a function.
repeat doesn't exist as an executable or function.
And, if I were doing this, I'd get rid of "seq" completely (*) and just
code the loop in "repeat" as:
for ((i=1; i<=count; i++)); do
(*) Thereby eliminating the "shadowing" issue.
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers.
If you have nothing useful to say, then just click Next and go on.
--
Chris Elvidge
England