Having read the docs and following this answer, I wanted to test it with a simple example:
test_1.sh
#!/usr/bin/bash
let x=1/0
echo $x
test_2.sh
#!/usr/bin/bash
printf "\nThis is 2\n"
But both of these implementations of control flow fail: run test_1, if unsuccessful, run test_2
# Just errors on line 1 of course
./test_1.sh
if [ $? -ne 0 ]; then
./test_2.sh
fi
Also fails:
./test_1.sh || ./test_2.sh
Any tips for controlling flow between multiple scripts?
||
between the scripts, is the exit status ofecho
. Is that what you expect? – Kusalananda Mar 01 '22 at 08:37let x=1/0
– Romeo Ninov Mar 01 '22 at 08:37test_1.sh
that could result in success (return code 0), or failure (anything other than 0). I want something liketest_2.sh
to run only in the former case. – Wassadamo Mar 02 '22 at 00:26