On Centos my script work fine. But on Debian Squeeze when I run script, I got:
cpfailover.sh: 30: Bad substitution
Line of script say:
SCRIPT_PATH="${BASH_SOURCE[0]}";
I have seen in many examples, even here, that is a correct line no. where is the problem.
${BASH_SOURCE[0]}
? AFAIK they should be the same.${BASH_SOURCE[@]}
is introduced in Bash 3.0 for debugging purpose. It does not mean the same as$0
. According to Bash manual, elements in${BASH_SOURCE[@]}
are the source filenames corresponding to the elements in${FUNCNAME[@]}
.