[Bash-completion-devel] [bash-completion-Bugs][314720] "set -o posix" in test/config/bashrc breaks bash-valid code.

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Tue Jul 1 20:57:16 UTC 2014


bash-completion-Bugs item #314720 was changed at 01/07/2014 22:57 by Dams Nadé
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=314720&group_id=100114

Status: Closed
Priority: 3
Submitted By: Dams Nadé (anvil-guest)
Assigned to: Nobody (None)
Summary: "set -o posix" in test/config/bashrc breaks bash-valid code. 
Distribution: None
Originally reported in: None
Milestone: None
Status: Fix Committed
Original bug number: 


Initial Comment:
#314716, I've submitted a function with a <() construction. While this is valid bash syntax, it cannot be parsed by bash if posix mode is enabled.

I would say "set -o posix" plays against the "Use the full power of bash >= 4.1" statement from the README file, CONTRIBUTING section.

Since a lot of bash completion code is not POSIX compliant ([[, arrays, extglob, etc....), I would suggest *disabling* posix mode in the test suite bashrc configuration file.

----------------------------------------------------------------------

Comment By: Dams Nadé (anvil-guest)
Date: 01/07/2014 22:57

Message:
posix is not something you want to enforce.

Not only [[, arrays, local variables, extglob (which bash-completion enforces), printf -v, (( )) and many other constructions are definitely not posix but also it would be *impossible* to create a posix bash completion implementation. You could say that bash-completion breaks posixness on an almost-every-line basis.

Plus in posix mode, bash refuses to parse the <() substitution at all. While not currently used in bash-completion, I've submitted a few patch containing some of them. Try to work around these would bloat the code a bit more.

So it would perfectly make sense to disable posix in bash completion test suite, imho. 

---

And for the record about failglob, 
* "if it works with failglob it will work without"
* "if it fails with failglob, then it will also fail at some point when failglob is disabled".

Failglob only points at insecure patterns.

So methinks failglob should be kept in mind at all time and never be disabled for the purpose of testing and validating bash-completion code robustness. 

And by the way, applying all of my patches (attached to bug reports i've opened) fixes (iirc) all failglob issues detected by the test suite.

----------------------------------------------------------------------

Comment By: Ville Skyttä  (scop-guest)
Date: 01/07/2014 21:25

Message:
While the posix mode has this and possibly some limitations that make the shell less powerful, I think it is mostly a behavioral setting just like failglob, and we want bash-completion to work no matter if it's enabled or not.

For the <(...) case, we already have a handled case in-tree, see "grep -A 4 posix completions/make"

I've applied the second patch (with commit message improvements) as well as made _save_env save the state of shell variables.

----------------------------------------------------------------------

Comment By: Dams Nadé (anvil-guest)
Date: 14/06/2014 17:47

Message:
So here are 2 trivial patches. One to disable posix in test/config/bashr, the other to make the  _save_env function result posix-independant. 

----------------------------------------------------------------------

Comment By: Dams Nadé (anvil-guest)
Date: 14/06/2014 00:02

Message:
Disabling posix in test/config/bashrc actually breaks the test suite, but I think I've found the issue.

When posix is enabled, the "set" command (without any parameter) only shows variables, but when posix is disabled the same "set" command will also print functions definitions (with full functions body).

So depending of the posix option setting, the _save_env function in test/lib/library.exp will not dump the same things. So the function should be instead :

proc _save_env {{file ""}} {
    assert_bash_exec "{ (set -o posix ; set); declare -F; shopt -p; } > \"$file\""
}

I think it's okay to do this, because it's not about posix itself, it's more about the content we want to compare. 

( And maybe the _save_env should also dump "set -o" output, so that we know bash_completion does not change bash behaviour )

----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=314720&group_id=100114



More information about the Bash-completion-devel mailing list