[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bash will continue executing main code path instead of current code path
From: |
Thomas Deutschmann |
Subject: |
Bash will continue executing main code path instead of current code path on error |
Date: |
Thu, 18 Apr 2019 17:32:50 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 |
Hi,
Test script:
============
#!/bin/bash
failing_function() {
local foo=${1}
# force bad substitution
local bar=${${foo}_blah}
echo "You will never see this text!"
}
if [[ 1 -eq 1 ]]
then
# Current code path
failing_function
echo "I run after the failing_function!"
else
# Alternative code path
echo "Will never run."
fi
# Main code path
echo "Rest of the script"
Actual result:
==============
bash-test.sh: line 5: bar=${${foo}_blah}: bad substitution
Rest of the script
Expected result:
================
bash-test.sh: line 5: bar=${${foo}_blah}: bad substitution
I run after the failing_function!
Rest of the script
Is my expectation wrong? I am really wondering that the script will
continue but not in the current if clause...
Tested with:
> GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
--
Regards,
Thomas Deutschmann / Gentoo Linux Developer
C4DD 695F A713 8F24 2AA1 5638 5849 7EE5 1D5D 74A5
- Bash will continue executing main code path instead of current code path on error,
Thomas Deutschmann <=