Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 259835 - dev-vcs/monotone-0.40[bash-completion]: extglob handling broken
Summary: dev-vcs/monotone-0.40[bash-completion]: extglob handling broken
Status: RESOLVED DUPLICATE of bug 267788
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Daniel Black (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-21 17:52 UTC by Martin von Gagern
Modified: 2010-07-18 08:20 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Gagern 2009-02-21 17:52:44 UTC
When emerged with the bash-completion USE flag, monotone will install a completion file into /usr/share/bash-completion/monotone. This file defines a bunch of functions which rely on the extglob shell option being set. It also contains a check to set the option if it isn't set already, and unset it again once the script is done.

The problem with this is that for things to work, the extglob feature has to be enabled when the functions are actually executed, not when they are defined. Thus the current code to set the option is either too much or too little effort to make things right.

It could be too much effort. Other packages, like bzr, mercurial and subversion on my system, simply set extglob unconditionally. This way it will remain set unless the user actively unsets it again, in which case he is to blame.

It might be too little effort. Keeping the user's environemtn clean is commendable. To work correctly, however, al that setting and unsetting of the extglob option would need to be done inside the _monotone function. I'm also not convinced that the code will behave correctly in the presence of already installed traps. It should probably restore all previous handlers and invoke the one appropriate for the signal received. The current code seems to invoke all previous handlers, and restore all unset handlers to their default, but not restore any handlers previously present.

I guess some kind of consensus would be desirable as to whether or not it is acceptable for bash completion modules to set and rely on extglob. If it is, all that conditional stuff could be dropped, and extglob set unconditionally. If it is not, then someone would need to work out a code snipped that reliably sets extglob for a single function call and restores everything to its previous state, even in the presence of signals, traps, errors, and whatnots. Then this code could be used by all bash-completion modules installed by portage, and als pushed upstream.

In any case, the current code in the monotone bash completion script doesn't work as intended, thus it's broken, thus it's a bug, albeit a minor one.

Steps to reproduce:
1. USE=bash-completion emerge monotone
2. cd some/monotone/working/directory
3. shopt -u extglob
4. . /usr/share/bash-completion/monotone
5. shopt extglob
6. type "mtn diff b:" and press tab twice
7. shopt extglob
8. shopt -s extglob
9. type "mtn diff b:" and press tab twice

Actual results:
5. extglob off
6. no completions suggested
7. extglob off
9. list of branches suggested as completions

Expected results with simple approach:
5. extglob on
6. list of branches
7. extglob on
9. list of branches

Expected results with elaborate approach:
5. extglob off
6. list of branches
7. extglob off
9. list of branches
Comment 1 Daniel Black (RETIRED) gentoo-dev 2009-04-28 10:38:26 UTC
ok thanks for the detailed explanation.

Unfortunately I don't know enough about bash-completion. If you could start a discussion on the gentoo-dev email list that would be great. At least we'll be consistent then.
Comment 2 Martin von Gagern 2009-04-28 16:36:10 UTC
(In reply to comment #1)
> Unfortunately I don't know enough about bash-completion. If you could start a
> discussion on the gentoo-dev email list that would be great. At least we'll be
> consistent then.

I'm not a Gentoo developer, not subscribed to that list, so I don't fell much like starting a discussion there. I also believe the number of people likely to give input on this to be rather small, i.e. those maintaining bash-completion. If you disagree, feel free to start a discussion, pointing at these bugs here.

I think I found a solution after some chatting on freenode. I just filed bug 267788 about it, with many references back here. I hope that bug will be assigned to the bash-completion maintainers, and that they will incorporate my suggestion. If they do, patching monotone to use this should be pretty easy.

As a side note: the steps to reproduce outlined in comment 0 don't seem to work for me today with bash 4.0, as it splits words after the colon in "b:". I could reproduce the issue and verify my solution using bash 3.1, though.
Comment 3 Daniel Black (RETIRED) gentoo-dev 2010-07-18 04:26:26 UTC
seems like this is being handled elsewhere. sorry for the lack of understanding of what can be done.

*** This bug has been marked as a duplicate of bug 267788 ***
Comment 4 Martin von Gagern 2010-07-18 08:20:44 UTC
(In reply to comment #3)
> *** This bug has been marked as a duplicate of bug 267788 ***

You've just duped a "minor" bug report to an enhancement request. Doesn't feel right to me.

Furthermore, bug 267788 is about introducing a new function "_with_shopt" to /usr/share/bash-completion/.pre while one fix for this bug here would require the monotone completion script to make use of that function. In this case, having this bug here depend on that one would be preferable.

Once bug 267788 gets implemented, I will gladly offer a patch for monotone, making use of this new functionality. As that bug is waiting for bash-completion upstream to accept the patch first, and as upstream hasn't posted a single comment on the report yet, I'm quite unsure about the timescale we're dealing with.