[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
exit status question
From: |
Curtis Doty |
Subject: |
exit status question |
Date: |
Mon, 20 Dec 2010 10:25:47 -0800 (PST) |
Not exactly sure if this is a bug. But I don't understand why only the
first time running ((i++)) returns an error exit status.
Here's my script:
#! /bin/bash
echo $BASH_VERSION ${BASH_VERSINFO[5]}
set -x
#set -e
i=0
((i++))
echo $?
((i++))
echo $?
And here's what the output looks like:
4.1.7(1)-release x86_64-redhat-linux-gnu
+ i=0
+ (( i++ ))
+ echo 1
1
+ (( i++ ))
+ echo 0
0
Is there something tricky going on here? Why exit 1 the first time, but
then normally every successive time? As you can see, I cannot set -e
because it will just exit the script. Uncommented it above and it does
this:
4.1.7(1)-release x86_64-redhat-linux-gnu
+ set -e
+ i=0
+ (( i++ ))
Doh! That was not an error.
../C
- exit status question,
Curtis Doty <=