help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Source builtin and error handling


From: Marcin Świgoń
Subject: [Help-bash] Source builtin and error handling
Date: Mon, 30 Nov 2015 21:58:58 +0100

Dear bash experts,

Today I came across a strange situation when using set -e, source
builtin and error handling.

Please consider following scripts:

#====================
# source run_this
#====================
source src1 || exit 1
echo "run_this: should I get here after src1?"
source src2 || exit 1
echo "run_this: should I get here after src2?"

#====================
# source src1
#====================
set -e
false
echo "src1: should I get here?"

#====================
# source src2
#====================
set -e
source src3 || echo "src3 does not exist"
false
echo "src2: should I get here?"

#========================
# output
#========================
> bash run_this
src1: should I get here?
run_this: should I get here after src1?
src2: line 2: src3: No such file or directory
src3 does not exist

Is this anyhow documented?
Is this behaviour desired (sub-source with error handling magically
activate set -e)?

GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)

Best Regards,
Marcin



reply via email to

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