rcaloras / bash-preexec

⚡ preexec and precmd functions for Bash just like Zsh.
MIT License
865 stars 94 forks source link

Compatibility with "nounset" bash option (fixed for bash 4.3) #84

Closed steinarvk closed 5 years ago

steinarvk commented 5 years ago

As noted in #80 , the main actual issue here is that because we install a DEBUG trap, our code may run even in contexts where the user thinks they've set bash options for their own code only. As such, it would be nice if we were very well behaved.

It's easier to just run the tests entirely under this option -- that saves us from having to think about which code needs to be nounset-safe and which code does not.

The actual code changes are pretty trivial, it's just a matter of applying them consistently, which the tests will enforce. (For whatever version of bash is running on Travis, which currently is 4.3 . We should probably test multiple versions of bash.)

This is based off the upgrade-bats branch which was sent as a separate pull request; https://github.com/rcaloras/bash-preexec/pull/83 .