[Top][All Lists]

[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
set -x
#set -e
echo $?
echo $?

And here's what the output looks like:

4.1.7(1)-release x86_64-redhat-linux-gnu
+ i=0
+ (( i++ ))
+ echo 1
+ (( i++ ))
+ echo 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]