niieani / bash-oo-framework

Bash Infinity is a modern standard library / framework / boilerplate for Bash
https://github.com/niieani/bash-oo-framework/discussions
MIT License
5.57k stars 247 forks source link

Unbound variables cause a crash when running examples with 'set -u' #65

Open adudek opened 6 years ago

adudek commented 6 years ago

tested in bash 4.3+ when setting 'set -u' in example/array.sh, I receive: bash-oo-framework/lib/util/command.sh: line 34: $3: unbound variable

there are more errors elsewhere, after performing "${unboundvar:-}"

Is this conscious design decision related to bash version? Sometimes I want my script to fail, not to cause more mayhem in unpredictable way. How to overcome this?

niieani commented 6 years ago

Hi @adudek! The framework was not tested with set -u - we'd like to fix it, and unbound vars are a known issue, if I'm not mistaken @tterranigma was trying to track them down and fix them. we're brainstorming a simplification of the framework in #45.

adudek commented 6 years ago

Note for future: "most sane" bash settings that I recommend should include at least: set +H -euo pipefail (-e should be suppressed only in try block) it is a pain to handle all potentially unassigned values, but less than potentially destroying data :)

niieani commented 6 years ago

Yes, I totally agree @adudek. We'll take this into consideration when planning 3.0. Thanks for your feedback!