Re: zsh style associative array assignment bug

2021-03-29 Thread Andreas Schwab
On Mär 28 2021, Greg Wooledge wrote: > Python is different: > y = ["a", "b", "c", "d"] dict(zip(y[::2], y[1::2])) > {'a': 'b', 'c': 'd'} x = ["a", "b", "c"] dict(zip(x[::2], x[1::2])) > {'a': 'b'} > > It seems to discard the last (unmatched) value. >>> dict(zip_longest(x[::2],

Re: zsh style associative array assignment bug

2021-03-29 Thread Ilkka Virta
On Mon, Mar 29, 2021 at 1:56 AM Greg Wooledge wrote: > Python is different: > > >>> y = ["a", "b", "c", "d"] > >>> dict(zip(y[::2], y[1::2])) > {'a': 'b', 'c': 'd'} > >>> x = ["a", "b", "c"] > >>> dict(zip(x[::2], x[1::2])) > {'a': 'b'} > > It seems to discard the last (unmatched) value. Also, d

Default PS1

2021-03-29 Thread ილია ჩაჩანიძე
How can I set default PS1 variable from source code? E.g I want it to display: My-linux-distro $ And not: Bash-5.1 $

Re: Default PS1

2021-03-29 Thread Chris Elvidge
On 29/03/2021 12:04 pm, ილია ჩაჩანიძე wrote: How can I set default PS1 variable from source code? E.g I want it to display: My-linux-distro $ And not: Bash-5.1 $ Set it in $HOME/.bashrc -- Chris Elvidge England

Re: Default PS1

2021-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2021 at 01:42:10PM +0100, Chris Elvidge wrote: > On 29/03/2021 12:04 pm, ილია ჩაჩანიძე wrote: > > How can I set default PS1 variable from source code? > > E.g I want it to display: > > My-linux-distro $ > > And not: > > Bash-5.1 $ > > > > Set it in $HOME/.bashrc Given that the go

Re: about the local not-on-every-function-separately var issue

2021-03-29 Thread Chet Ramey
On 3/22/21 9:38 PM, Dale R. Worley wrote: In my experience, a common reason is that the documentation does not concentrate in one place that users are certain to read, a complete, clear description of the situation. For instance, you give a complete, clear description: Bash uses "dynamic

Re: Changing the way bash expands associative array subscripts

2021-03-29 Thread Chet Ramey
On 3/15/21 8:32 PM, L A Walsh wrote:    That said, I'd want to see those examples in the manpage. FWIW -- I seem to remember that the manpage could use some more simple examples in a few places. Examples are more for the texinfo documentation; the man page is big enough already. -- ``The lyf

Re: Changing the way bash expands associative array subscripts

2021-03-29 Thread Chet Ramey
On 3/15/21 9:03 PM, Léa Gris wrote: zsh also provide a nice feature to iterate both keys and values in a single loop: for key value in "${(kv)assoc_array}"; do     printf '%s -> %s\n' "$key" "$value" done I don't have any current interest in implementing the zsh mini-language for expansion

Re: Changing the way bash expands associative array subscripts

2021-03-29 Thread Chet Ramey
On 3/16/21 8:34 AM, Greg Wooledge wrote: I would not complain if unset became a shell keyword I'm not considering this. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://ti

Re: Changing the way bash expands associative array subscripts

2021-03-29 Thread Chet Ramey
On 3/15/21 9:41 PM, Koichi Murase wrote: 2021年3月16日(火) 8:12 Chet Ramey : key='x],b[$(echo uname >&2)' (( assoc[$key]++ )) [...] declare -A assoc=(["x],b[\$(echo uname >&2)"]="1" ) I agree with this change. I think the same rule should apply also to the indexed arrays in the arithmetic command.

Re: why does this define bla() instead of respect the newline as command separator

2021-03-29 Thread Chet Ramey
On 3/19/21 10:59 AM, Oğuz wrote: Not much related, but isn't this supposed to work? $ cat foo.sh alias c='case ' w='foo ' i='in ' p=') ' e='esac' u='uname ' s='; ' c w i e Bash is pretty careful not to perform alias expansion in case statement pattern lists, even to the point where that over

parent trap EXIT appears to subshell but is not used

2021-03-29 Thread Valentin Lab
Hi, I have encountered an issue when running some bash code from 4.3 that behave in an unexpected way on 4.4 or 5 ... I've managed to pinpoint the exact issue on my end. Here is the code: ## trap -- 'echo bar' EXIT ( echo -n 'Subshell TRAP EXIT: ' trap -p EXIT echo )

Re: why does this define bla() instead of respect the newline as command separator

2021-03-29 Thread Alex fxmbsw7 Ratchev
case statements are imho string comparision, nothing to do with aliases On Mon, Mar 29, 2021, 17:23 Chet Ramey wrote: > On 3/19/21 10:59 AM, Oğuz wrote: > > > Not much related, but isn't this supposed to work? > > > > $ cat foo.sh > > alias c='case ' w='foo ' i='in ' p=') ' e='esac' u='uname ' s

parent trap EXIT appears to subshell but is not used

2021-03-29 Thread Oğuz
29 Mart 2021 Pazartesi tarihinde Valentin Lab yazdı: > Hi, > > I have encountered an issue when running some bash code from 4.3 that > behave in an unexpected way on 4.4 or 5 ... I've managed to pinpoint the > exact issue on my end. > > Here is the code: > > > ## > trap -- 'echo

Re: why does this define bla() instead of respect the newline as command separator

2021-03-29 Thread Chet Ramey
On 3/29/21 12:04 PM, Alex fxmbsw7 Ratchev wrote: case statements are imho string comparision, nothing to do with aliases "'The question is,' said Humpty Dumpty, 'which is to be master — that’s all.'" -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, v

Re: Redirection between assignment statement and command name prevents alias substitution

2021-03-29 Thread Chet Ramey
On 3/25/21 2:00 AM, Oğuz wrote: I'm not sure why you want or need that, aliases are dumb (bizarre) and shoukd be deleted... I keep trying to get tge POSIX people to remove them from the standard. They keep ignoring me. Shells won't drop support, but at least no-one woukd be able to rely on th

Re: parent trap EXIT appears to subshell but is not used

2021-03-29 Thread Robert Elz
Date:Mon, 29 Mar 2021 17:31:23 +0200 From:Valentin Lab Message-ID: <604a4dab-afc5-cd5e-ee80-64d3dfb2e...@kalysto.org> | In 4.3, this makes sense to me. EXIT trap is not available and not executed. | | In >4.3, I don't understand: 'trap -p' is displaying a trap

Re: Default PS1

2021-03-29 Thread L A Walsh
On 2021/03/29 04:04, ილია ჩაჩანიძე wrote: How can I set default PS1 variable from source code? --- What do you mean "from source code?" E.g I want it to display: My-linux-distro $ And not: Bash-5.1 $ --- Does the procedure documented in the bash man page not work? Or, what do you me

Re: zsh style associative array assignment bug

2021-03-29 Thread L A Walsh
On 2021/03/28 11:02, Eric Cook wrote: On 3/28/21 7:02 AM, Oğuz wrote: As it should be. `[bar]' doesn't qualify as an assignment without an equals sign, the shell thinks you're mixing two forms of associative array assignment there. In the new form, that a key is listed inside a compound as

Re: zsh style associative array assignment bug

2021-03-29 Thread Chet Ramey
On 3/27/21 5:02 PM, Eric Cook wrote: Hey, When doing an assignment with an uneven number of elements bash currently silently treat the last element as a key and assigns it an empty string. $ typeset -A ary=(this feature came from zsh); typeset -p ary declare -A ary=([came]="from" [this]="feat

Re: Default PS1

2021-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2021 at 01:49:41PM -0700, L A Walsh wrote: > Or, what do you mean by 'default'? Is it sufficient > to set it in the system /etc/profile so it is the default > for all users when logging in? Sadly, that won't work. There are plenty of *extremely* common paths from power-on to shel

Re: zsh style associative array assignment bug

2021-03-29 Thread Eric Cook
On 3/29/21 5:18 PM, Chet Ramey wrote: If you look at a=( k1 v1 k2 v2 k3 v3) as more or less syntactic sugar for a=( [k1]=v1 [k2]=v2 [k3]=v3 ) it's reasonable that a=( k1 v1 k2 ) is equivalent to a=( [k1]=v1 [k2]= ). And that's what bash does. Its just when populating that array dynamic

Re: Changing the way bash expands associative array subscripts

2021-03-29 Thread Marco Ippolito
> Examples are more for the texinfo documentation; the man page is big > enough already. What goes in the man page Vs in the texinfo documentation, please?

Re: Default PS1

2021-03-29 Thread Christopher Dimech
In your .bashrc you can do PS1='My-linux-distro $\n' - Christopher Dimech General Administrator - Naiad Informatics - GNU Project (Geocomputation) - Geophysical Simulation - Geological Subsurface Mapping - Disaster Preparedness and Mitigation - Natural Resource Exploration an

Re: Default PS1

2021-03-29 Thread Greg Wooledge
On Mon, Mar 29, 2021 at 07:25:53PM -0700, L A Walsh wrote: > On 2021/03/29 14:39, Greg Wooledge wrote: > > On Mon, Mar 29, 2021 at 01:49:41PM -0700, L A Walsh wrote: > > > Or, what do you mean by 'default'? Is it sufficient > > > to set it in the system /etc/profile so it is the default > > > for

Re: Default PS1

2021-03-29 Thread L A Walsh
On 2021/03/29 14:39, Greg Wooledge wrote: On Mon, Mar 29, 2021 at 01:49:41PM -0700, L A Walsh wrote: Or, what do you mean by 'default'? Is it sufficient to set it in the system /etc/profile so it is the default for all users when logging in? Sadly, that won't work. There are plenty o

Re: parent trap EXIT appears to subshell but is not used

2021-03-29 Thread Oğuz
29 Mart 2021 Pazartesi tarihinde Robert Elz yazdı: > Date:Mon, 29 Mar 2021 17:31:23 +0200 > From:Valentin Lab > Message-ID: <604a4dab-afc5-cd5e-ee80-64d3dfb2e...@kalysto.org> > > > | In 4.3, this makes sense to me. EXIT trap is not available and not > executed. >