Summary
import changes directories with pushd / popd while sourcing a library. If the sourced file exits through exit_if_error or another early failure path, popd may never run and the shell directory stack can be polluted.
Action
- Resolve relative imports against
__SCRIPT_DIR__ without changing directories.
- Keep absolute import behavior unchanged.
- Add regression coverage for failed imports and relative imports.
Source
From the lib_std.sh Evolution Suggestions review item: "import uses pushd/popd, which is fragile under early exit."
Summary
importchanges directories withpushd/popdwhile sourcing a library. If the sourced file exits throughexit_if_erroror another early failure path,popdmay never run and the shell directory stack can be polluted.Action
__SCRIPT_DIR__without changing directories.Source
From the
lib_std.sh Evolution Suggestionsreview item: "importusespushd/popd, which is fragile under early exit."