Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread Stan Marsh
>>Sure, except this isn't a script. It's in a file named Bash_aliases >>contained in a directory named examples/startup-files. It was clearly >>intended to be copied into one's ~/.bashrc file (or to be dotted in >>from there). >>Including it in your ~/.bashrc would effectively mask the real se

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread pourko--- via Bug reports for the GNU Bourne Again SHell
On Sat, 20 Sep 2025 15:57:08 -0400 Greg Wooledge wrote: > I have two -- no, three -- no, four -- issues with this function: > >  1) It's overriding the seq(1) command on systems which have one, with > a less capable alternative. >  2) It's "off by one" if you provide two sensible inputs.  This

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread Chris Elvidge
On 21/09/2025 at 13:37, Greg Wooledge wrote: On Sun, Sep 21, 2025 at 13:04:59 +0200, pourko--- via Bug reports for the GNU Bourne Again SHell wrote: On Sat, 20 Sep 2025 15:57:08 -0400 Greg Wooledge wrote: I have two -- no, three -- no, four -- issues with this function: 1) It's overriding

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread Phi Debian
It is fine to keep the relics :-) I used that more as an exercise about how to do it in modern bash. If one can find a shorter one, or a faster one, would be nice to know :-) thats how I learn bash, by looking others examples... reading the docco in last resort :-) Cheer,

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread Greg Wooledge
On Sun, Sep 21, 2025 at 13:04:59 +0200, pourko--- via Bug reports for the GNU Bourne Again SHell wrote: > On Sat, 20 Sep 2025 15:57:08 -0400 Greg Wooledge wrote: > > I have two -- no, three -- no, four -- issues with this function: > > > >  1) It's overriding the seq(1) command on systems which h

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread Stan Marsh
>May be the 'repeat' function in the 'examples' is a bit lengthy, and use >subshells, the example I got is ... I think all of the files in the examples/startup-files directory should be treated as museum pieces. You wouldn't go into a museum and start insisting that all the displays be changed

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-21 Thread Phi Debian
May be the 'repeat' function in the 'examples' is a bit lengthy, and use subshells, the example I got is === # "repeat" command. Like: # # repeat 10 echo foo repeat () { local count="$1" i; shift; for i in $(seq 1 "$count"); do eval "$@";

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Robert Elz
Date:Sat, 20 Sep 2025 15:57:08 -0400 From:Greg Wooledge Message-ID: <20250920195708.gt22...@wooledge.org> | 2) It's using eval "$@". This is just bad. | It should either be using "$@" without eval, That I agree is the way it should be. However: | o

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Greg Wooledge
On Sat, Sep 20, 2025 at 21:25:44 +0200, pourko--- via Bug reports for the GNU Bourne Again SHell wrote: > > Also, the provided seq function shadows /usr/bin/seq > > [...] The patch to fix these issues... > > Shadowing a command is not really an "issue". > > In this example, a function shadows an

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread pourko--- via Bug reports for the GNU Bourne Again SHell
> Also, the provided seq function shadows /usr/bin/seq > [...] The patch to fix these issues... Shadowing a command is not really an "issue". In this example, a function shadows an external command, hence it is in the examples dir.

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Chris Elvidge
On 20/09/2025 at 15:22, Martin Schulte wrote: Hello, I try to resolve the confusion: Am Sat, 20 Sep 2025 14:56:05 +0100 schrieb Chris Elvidge : ... 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

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Lawrence Velázquez
On Sat, Sep 20, 2025, at 9:03 AM, Stan Marsh wrote: > 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 p

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Chris Elvidge
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

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Martin Schulte
Hello, I try to resolve the confusion: Am Sat, 20 Sep 2025 14:56:05 +0100 schrieb Chris Elvidge : > ... > 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. In the bash source tree yo

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Stan Marsh
> 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. To fix that, you need to "dot" (aka, "source") the file Bash_aliases, which you will find in the "examples/startup-files" subdirecto

[PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Stan Marsh
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 h

Re: [PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-20 Thread Chris Elvidge
On 20/09/2025 at 00:01, Gioele Barabucci wrote: From: Nicolas Aupetit The `repeat` function calls the provided command one time too many: repeat 10 echo "foo" | wc -l ⇒ 11 Surely that depends on your definition of repeat. Do it and repeat it 10 times vs. Do it a total of 10 times -- C

[PATCH] examples/s-f/Bash_aliases: Fix off-by-one error

2025-09-19 Thread Gioele Barabucci
From: Nicolas Aupetit The `repeat` function calls the provided command one time too many: repeat 10 echo "foo" | wc -l ⇒ 11 Also, the provided `seq` function shadows `/usr/bin/seq`. The patch to fix these issues has originally been provided by Nicolas Auperit in