On 8/28/2020 1:00 AM, Gabriel Winkler wrot
> # Causes error
> test=0
> ((test++))
> echo $?
> 1
> echo $test
> 1
>
"((...))" is the "test form" for an integer expression. That means
it will return true if the value of the interior, "...", of "((...))"
is non-zero and return false if ((... ==
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.
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_
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'
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'
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'