Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Binarus
Thank you very much for your effort, testing and support! On 29.08.2020 01:46, Koichi Murase wrote: > 2020-08-28 22:04 Binarus : >> Description: >> >> >> Under certain circumstances, assignments of namerefs to local variables >> in functions behaves in a way which makes namerefs compl

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Binarus
At first, thank you very much for your effort and the understandable explanation. On 28.08.2020 20:28, Robert Elz wrote: > Date:Fri, 28 Aug 2020 18:25:23 +0200 > From:Binarus > Message-ID: <8313a366-6ecd-5e87-5552-6a4e0fe18...@binarus.de> > > > | > This doesn't ma

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Binarus
On 28.08.2020 22:08, Oğuz wrote: > > 5.1 is still in beta phase. I see. I couldn't use it anyway because the script in question (where I make heavy use of namerefs and nested function calls) is for production, and I won't use software which I need to compile myself on those servers for security

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Koichi Murase
2020-08-28 22:04 Binarus : > Description: > > > Under certain circumstances, assignments of namerefs to local variables > in functions behaves in a way which makes namerefs completely useless. > Furthermore, the behavior is not consistent. This is actually not related to namerefs and

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Oğuz
28 Ağustos 2020 Cuma tarihinde Binarus yazdı: > > > On 28.08.2020 17:37, Oğuz wrote: > > 28 Ağustos 2020 Cuma tarihinde Greg Wooledge > yazdı: > > > >> On Fri, Aug 28, 2020 at 10:56:34AM +0200, Binarus wrote: > >>> #!/bin/bash > >>> > >>> function Dummy() { > >>> > >>> local -n namerefArray="$

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Robert Elz
Date:Fri, 28 Aug 2020 18:25:23 +0200 From:Binarus Message-ID: <8313a366-6ecd-5e87-5552-6a4e0fe18...@binarus.de> | > This doesn't make the slightest sense. What is the point of having local | > variables then? | | Or namerefs ... I totally agree. Either locals

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Greg Wooledge
On Fri, Aug 28, 2020 at 06:20:04PM +0200, Binarus wrote: > However, the main question is why leaving away the -a and -i in the > second script makes things work as expected. I'll leave aside my usual rant about -i for now. Here's your original code: #!/bin/bash function Dummy() { local -n na

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Binarus
On 28.08.2020 17:37, Oğuz wrote: > 28 Ağustos 2020 Cuma tarihinde Greg Wooledge yazdı: > >> On Fri, Aug 28, 2020 at 10:56:34AM +0200, Binarus wrote: >>> #!/bin/bash >>> >>> function Dummy() { >>> >>> local -n namerefArray="$1" >>> local -a -i myArray=("${namerefArray[@]}") >>> >>> local

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Binarus
On 28.08.2020 17:28, Greg Wooledge wrote: > On Fri, Aug 28, 2020 at 10:56:34AM +0200, Binarus wrote: >> #!/bin/bash >> >> function Dummy() { >> >> local -n namerefArray="$1" >> local -a -i myArray=("${namerefArray[@]}") >> >> local -p >> } >> >> declare -a -i myArray=('1' '2' '3') > > You

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Greg Wooledge
On Fri, Aug 28, 2020 at 06:37:00PM +0300, Oğuz wrote: > 28 Ağustos 2020 Cuma tarihinde Greg Wooledge yazdı: > > func1() { > > declare -n _func1_ref="$1" > > local _func1_i > > ... > > } > > > This doesn't make the slightest sense. What is the point of having local > variables then? You need

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Oğuz
28 Ağustos 2020 Cuma tarihinde Greg Wooledge yazdı: > On Fri, Aug 28, 2020 at 10:56:34AM +0200, Binarus wrote: > > #!/bin/bash > > > > function Dummy() { > > > > local -n namerefArray="$1" > > local -a -i myArray=("${namerefArray[@]}") > > > > local -p > > } > > > > declare -a -i myArray=('

Re: Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Greg Wooledge
On Fri, Aug 28, 2020 at 10:56:34AM +0200, Binarus wrote: > #!/bin/bash > > function Dummy() { > > local -n namerefArray="$1" > local -a -i myArray=("${namerefArray[@]}") > > local -p > } > > declare -a -i myArray=('1' '2' '3') You've got a local variable with the same name as the global

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread Greg Wooledge
On Fri, Aug 28, 2020 at 08:00:30AM +, Gabriel Winkler wrote: > # Causes error > test=0 > ((test++)) > echo $? > 1 > echo $test > 1 https://mywiki.wooledge.org/BashFAQ/105 Exercise 1. And 2. And the whole rest of the page.

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread Ilkka Virta
On Fri, Aug 28, 2020 at 4:04 PM Gabriel Winkler wrote: > # Causes error > test=0 > ((test++)) > echo $? > 1 > It's not an error, just a falsy exit code. An error would probably give a message. But to elaborate on the earlier answers, the value of the post-increment expression var++ is the _old_

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread Chris Elvidge
On 28/08/2020 09:00 am, Gabriel Winkler wrote: Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4 -L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0 Compilation CFLAGS: -DPROGRAM='bash' -DCON

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread
On 28/08/2020 09:00, Gabriel Winkler wrote: Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4 -L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0 Compilation CFLAGS: -DPROGRAM='bash' -DCONF_H

Incorrect / Inconsistent behavior with nameref assignments in functions

2020-08-28 Thread Binarus
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR$ uname output: Linux cerberus

Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread Gabriel Winkler
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4 -L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0 Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -D