rawiriblundell / sh_libpath

Making shell scripts more robust with libraries
Apache License 2.0
11 stars 2 forks source link

Dynamically rebuild SH_LIBS_LOADED #14

Open rawiriblundell opened 2 years ago

rawiriblundell commented 2 years ago

Minor edge case: If a library/function is loaded, and then manually unset, then _is_lib_loaded() is going to be tricked into believing that the function is still loaded.

Steps to reproduce: Well... you should really get your parents to give you 'the talk' ;)

Steps to make this thing blow up for you too:

  1. import text/str_altcaps.sh
  2. unset str_altcaps
  3. import str_altcaps from text

Step 3 invokes _is_lib_loaded() which checks SH_LIBS_LOADED, rather than the environment, it thinks that str_altcaps is loaded, so it hits return 0. At the time of logging this issue, import x from y is broken, so I'd expect to see SH_STACK dumped out.

This is obviously more of an issue for interactive usage rather than scripted usage, hence its "minor" status.

rawiriblundell commented 1 year ago

Thought: import --reload text/caps