Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Oğuz
On Thursday, June 27, 2024, Martin D Kealey wrote: > [...] That's too much to read and Perl is not a good example to follow. Why not extend the arithmetic expansion syntax to allow generating multiple results when subscripting indexed arrays? Like `${a[1; 2; 4]}', `${a[3..5; 7]}', `${a[1..10..3

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Martin D Kealey
On Thu, 27 Jun 2024 at 06:30, Chet Ramey wrote: > On 6/26/24 2:18 PM, Zachary Santer wrote: > > >> On Tue, Jun 11, 2024, 12:49 PM Zachary Santer > wrote: > >>> > >>> $ array=( zero one two three four five six ) > >>> $ printf '%s\n' "${array[@]( 1 5 )}" > >>> one > >>> five > > > > This is diffe

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread Martin D Kealey
I've found some existing code that will break if words in ${BASH_SOURCE[@]} don't match the filepath given to '.' or 'source': [[ ${BASH_ARGV[0]} = "${BASH_SOURCE[0]}" ]] which is part of a test to determine whether any args were provided after "source filename". I use this at the end of my file

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Zachary Santer
On Wed, Jun 26, 2024 at 2:30 PM Chet Ramey wrote: > > On 6/26/24 2:18 PM, Zachary Santer wrote: > > >> On Tue, Jun 11, 2024, 12:49 PM Zachary Santer wrote: > >>> > >>> $ array=( zero one two three four five six ) > >>> $ printf '%s\n' "${array[@]( 1 5 )}" > >>> one > >>> five > > > > This is diff

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread alex xmb sw ratchev
On Wed, Jun 26, 2024, 8:30 PM Chet Ramey wrote: > On 6/26/24 2:18 PM, Zachary Santer wrote: > > >> On Tue, Jun 11, 2024, 12:49 PM Zachary Santer > wrote: > >>> > >>> $ array=( zero one two three four five six ) > >>> $ printf '%s\n' "${array[@]( 1 5 )}" > >>> one > >>> five > > > > This is diffe

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Chet Ramey
On 6/26/24 2:18 PM, Zachary Santer wrote: On Tue, Jun 11, 2024, 12:49 PM Zachary Santer wrote: $ array=( zero one two three four five six ) $ printf '%s\n' "${array[@]( 1 5 )}" one five This is different functionality. Equivalent to printf '%s\n' "${array[1}" "${array[5]}". The innovation

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread alex xmb sw ratchev
On Wed, Jun 26, 2024, 8:19 PM Zachary Santer wrote: > On Wed, Jun 26, 2024 at 11:19 AM alex xmb sw ratchev > wrote: > > > > printf %s\\n "${arr[@]:1:5}" > > For my array below, this would give you > one > two > three > four > five > > > On Tue, Jun 11, 2024, 12:49 PM Zachary Santer wrote: > >>

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Zachary Santer
On Wed, Jun 26, 2024 at 11:19 AM alex xmb sw ratchev wrote: > > printf %s\\n "${arr[@]:1:5}" For my array below, this would give you one two three four five > On Tue, Jun 11, 2024, 12:49 PM Zachary Santer wrote: >> >> $ array=( zero one two three four five six ) >> $ printf '%s\n' "${array[@](

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Greg Wooledge
On Wed, Jun 26, 2024 at 14:09:13 -0400, Zachary Santer wrote: > > > Imagine this functionality: > > > $ array=( zero one two three four five six ) > > > $ printf '%s\n' "${array[@]( 1 5 )}" > > > one > > > five > I did want to see if others would find this valuable, and no one spoke > up, so it's

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Zachary Santer
On Wed, Jun 26, 2024 at 10:58 AM Chet Ramey wrote: > > On 6/11/24 6:48 AM, Zachary Santer wrote: > > > My mind returns to this nonsense, as I find a use for it. > > > > Imagine this functionality: > > $ array=( zero one two three four five six ) > > $ printf '%s\n' "${array[@]( 1 5 )}" > > one > >

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread alex xmb sw ratchev
printf %s\\n "${arr[@]:1:5}" On Tue, Jun 11, 2024, 12:49 PM Zachary Santer wrote: > Was "bash tries to parse comsub in quoted PE pattern" > > On Wed, Oct 18, 2023 at 8:19 AM Zachary Santer wrote: > > > > In Bash 5.2: > > $ array=( zero one two three four five six ) > > $ printf '%s\n' "${array[

Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices

2024-06-26 Thread Chet Ramey
On 6/11/24 6:48 AM, Zachary Santer wrote: My mind returns to this nonsense, as I find a use for it. Imagine this functionality: $ array=( zero one two three four five six ) $ printf '%s\n' "${array[@]( 1 5 )}" one five I'm not inclined to implement this. I don't like the syntax and there are

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread Léa Gris
Le 26/06/2024 à 14:17, Martin D Kealey écrivait : Just to be clear, would this result in $0 and ${BASH_SOURCE[@]:(-1):1} potentially yielding different values? There is no reason it would alter the content of $0 which remains the name of the command involved. The arguments vector with index

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread konsolebox
On Wed, Jun 26, 2024 at 8:57 PM Chet Ramey wrote: > What `lazy alternatives' did you have in mind? I replied to Martin D Kealey about it but looking at the email now it seems like he's referring to something involving BASH_SOURCE_PATH instead of BASH_SOURCE. I misinterpreted. I'm thinking if pe

Re: DEBUG trap in a background shell steals controlling terminal forcing parent shell to exit

2024-06-26 Thread Chet Ramey
On 6/25/24 2:49 PM, Mark March wrote: Bump in case this fell through the cracks. My simple script that uses no job control facilities (in fact, turns job control off) if run in the background would log the user out on any keyboard input. This can't be right. Can you at least confirm that thi

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread Chet Ramey
On 6/26/24 5:59 AM, konsolebox wrote: That's great. So will this be implemented soon or will you consider other lazy alternatives first? What `lazy alternatives' did you have in mind? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' -

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread Martin D Kealey
On Wed, 26 Jun 2024, 03:14 Chet Ramey, wrote: > On 6/19/24 6:12 PM, konsolebox wrote: > > > Alternatively, have BASH_SOURCE always produce real physical paths > > either by default or through a shopt. > > This is the best option. I don't think changing bash to do this by default > would have nega

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread konsolebox
On Tue, Jun 25, 2024 at 11:14 PM Chet Ramey wrote: > > On 6/19/24 6:12 PM, konsolebox wrote: > > > Alternatively, have BASH_SOURCE always produce real physical paths > > either by default or through a shopt. > > This is the best option. I don't think changing bash to do this by default > would hav