Update stdlib.sh for correct operation within sub-shells and from invoked scripts