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
Defining a local variable in a function can remove export-bit outside of the function #2611
Comments
Should making a local change without explicitly saying the new value should be exported result in the var not being exported to any external command? If the answer is yes then external commands won't get the setting in effect for the shell (which is a big deal for LANG or the LC_* vars). In which case we can implicitly inherit the export attribute. Alternatively, we can define the semantics to be that the pre-existing value is still exported to external commands and the |
The relevant bit from the
That's a yes.
That's basically the previous rule:
The question here being of course whether a variable by the same name in a different scope counts as "previously defined". I'd be okay with interpreting it as such since for overrides like LC_* this would be what you want. Of course the docs should be adjusted to explicitly mention this. However, the main problem I see here is that defining a variable in a smaller scope alters variables in a bigger scope - meaning that a function can break stuff outside of it (and quite unintentionally). |
Okay, the issue here is the following: When a scope ends (i.e. if (top->new_scope) { //!OCLINT(collapsible if statements)
if (top->exportv || local_scope_exports(top->next.get())) {
this->mark_changed_exported();
}
} This is wrong in this case. The array needs to be recomputed, not because the dying scope has exported variables, but because it has variables that it removes from exporting. TBD is how we solve that - do we just always recompute the export-array when a scope ends? Presumably that has a performance impact. Alternatively, we could set a scope's "exportv" bool if the node changes something about exports, not just when it has exported variables. I've made that change locally and all tests still pass. |
I.e. the fix for fish-shell#2611.
Okay, I have now included this in #4149. |
The fix by @faho has been merged into the git |
Like @krader1961 says in #2601 (comment):
The text was updated successfully, but these errors were encountered: