2 ms·
this only works because you are sourcing the file, and not just executing it: $(exit 5) ./show_error.sh outputs 0. Sourcing the file is the same as copying a
by SuchAnonMuchWow 4y ago
this only works because you are sourcing the file, and not just executing it:
$(exit 5)
./show_error.sh
outputs 0.
Sourcing the file is the same as copying and pasting its content into the current shell. It is designed to allow this kind of things (accessing the caller execution context). But it is not what we usually call a script precisely because of this.