[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bash 3.2 vs 3.0
From: |
Dave |
Subject: |
bash 3.2 vs 3.0 |
Date: |
Thu, 5 Jan 2012 10:12:34 +0000 |
Hi all,
Recently upgraded to 3.2 and noticed some differences in a lot of my
scripts, consider the following example:
#!/bin/bash
trap error_reporter ERR
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
logf_error=/dev/null
function _exit
{
local -ri retval="${1:-$?}"
exit ${retval}
}
function error_reporter {
local -ri retval=$?
#echo "Error in script setup. Exiting with error value ${retval}."
local -i i=0
#echo "Function call stack:" >&2
while caller $i >&2; do (( i++ )); done
_exit ${retval}
}
function echo_aaaa { #this is called as a $(command)
#a subcommand might return with 1 in the script, but in most cases it is
not a problem.
#At least in our scripts there are a lot of cases like this where the error
is handled afterwards
echo "aaaa" | grep b
echo "Execution continues"
}
echo "Turning off errtrace"
set +o errtrace
var=$(echo_aaaa) #calling as a $(command)
echo $var
echo "Turning on errtrace"
set -o errtrace
echo "Next command will fail in bash3.2"
var=$(echo_aaaa) #calling as a $(command)
echo $var
Doesnt work right on 3.2
Output from 3.0
root@atrcus365:/# /tmp/test
/tmp/test
Turning off errtrace
Execution continues
Turning on errtrace
Next command will fail in bash3.2
Execution continues
root@atrcus365:/# echo $BASH_VERSION
echo $BASH_VERSION
3.00.16(1)-release
root@atrcus365:/#
Output from 3.2
root@atmwsnfd:/# /tmp/test
Turning off errtrace
Execution continues
Turning on errtrace
Next command will fail in bash3.2
26 echo_aaaa /tmp/test
42 main /tmp/test
42 main /tmp/test
root@atmwsnfd:/# echo $BASH_VERSION
3.2.51(1)-release
root@atmwsnfd:/#
Could anyone point me in correct direction on this one ?
Regards
Dave