Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adudek opened this issue Sep 27, 2018 · 3 comments
Open

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

adudek opened this issue Sep 27, 2018 · 3 comments

Comments

@adudek
Copy link

adudek commented Sep 27, 2018

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
Copy link
Owner

niieani commented Oct 5, 2018

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.

@niieani niieani changed the title set -u causes examples to fail Unbound variables cause a crash when running examples with 'set -u' Oct 5, 2018
@adudek
Copy link
Author

adudek commented Oct 6, 2018

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
Copy link
Owner

niieani commented Oct 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants