First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 55687
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Shell Tools Herd Bugs <shell-tools@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Peter Jensen <gentoo-bugs@pekaje.homeip.net>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
gentoo-equery Bash completion for 'equery' text/plain Peter Jensen 2004-06-30 08:54 0000 6.21 KB Details
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 55687 depends on: Show dependency tree
Bug 55687 blocks:
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2004-06-30 08:53 0000
Well, it's official ... Bash completion has spoiled me :-)
Finding no completion routines to work with 'equery', I decided that this was a good opportunity to learn how Bash completion works and scratch an itch at the same time.

------- Comment #1 From Peter Jensen 2004-06-30 08:54:51 0000 -------
Created an attachment (id=34492) [edit]
Bash completion for 'equery'

Any suggestions for improvements?

------- Comment #2 From Christian Birchinger 2004-06-30 12:50:41 0000 -------
Did you know that theres a gentoo-completion project on SourceForge now?

I've added the author and maintainer of it to CC and hope you could contact
him directly to get your great work integrated into it.

As he said before, he would hand out access to people if they want to help
him working with it. If you don't want that i'm sure he'll add your add-on
to the project to have one single place for gentoo-completion.

Looks good to me. Maybe the package completion could be merged into one
function which gets used by all gentoo completion functions which need
a category/package completion.

------- Comment #3 From Daniel Webert 2004-10-11 13:09:29 0000 -------
http://sourceforge.net/projects/gentoo-bashcomp/

------- Comment #4 From Aaron Walker (RETIRED) 2004-10-12 03:36:12 0000 -------
Zach, any plans on adding this to gentoo-bashcomp?

------- Comment #5 From Zach Forrest 2004-10-12 13:43:08 0000 -------
I'll add it in the next day or so. I only took a cursory glance at it, but it
looks good to me. (I will let you know if I do make any changes and why.)

In regards to a "universal" category/package name completion function, I'm all
for it. I'll take a look at the provided function and see how it fits in with
the needs of the other completion commands.

Thanks for the addition and feedback.

------- Comment #6 From Zach Forrest 2004-10-18 11:06:29 0000 -------
I've committed the changes to CVS and released 1.0_beta2 of gentoo-bashcomp. I
haven't done a lot of testing, but it seems to work as intended. I made some
relatively minor changes to the posted script. I've detailed my rationalle for
the changes below for those who are interested (exerpted from an e-mail I sent
to Peter Jensen):

"I changed the _pkgname function to also accept the current word as a
parameter. My rational is derived from Christian's suggestion that the
category/package name completion code be merged into one function. I
can't say that this change is absolutely necessary (I still have to dive
deeper in, and it's been a while since I looked at the code), but I
thought it safer not to modify $cur, so as not to potentially confuse
the calling function.

One thing I've found to be a pain to deal with is the $OLDPWD variable.
I believe I was looking through the bash_completion code one day and
noticed that when there was a change of directory, it was done within a
command substitution construct. For example, this

    # Are we completing a category?
    elif [[ ${prev} == "-c" || ${prev} == "--category" ]]
    then
        local oldpwd
        oldpwd=$OLDPWD
        cd /usr/portage/metadata/cache/
        COMPREPLY=($(compgen -W "$(compgen -G '*')" -- $cur))
        cd $OLDPWD
        OLDPWD=$oldpwd
    fi

becomes this

    # Are we completing a category?
    elif [[ ${prev} == "-c" || ${prev} == "--category" ]]; then
        COMPREPLY=($(cd /usr/portage/metadata/cache; compgen -W "$(compgen -G
'*')" -- $cur))
    fi

which makes it much more readable. Because the 'cd' command executes in
a subshell, the current environment is unaffected and, not surprisingly,
the user's $OLDPWD variable is left unchanged. There may be more
repetition in having to do the actual directory change, but it does get
rid of the $OLDPWD headache, which makes the code easier to follow and
more concise.

Other than that, I just made a few cosmetic and formatting changes for
consistency and combined the 'uses' and 'which' case in _equery, as the
code was the same in both."

I'm going to deal with making the _pkgname function more generic at another
time, as I think it will take a bit of thought to do properly.

I also added several new options to the emerge command and removed the rsync
action (replace by --sync, if I'm not mistaken) as its use has been deprecated.
I think all the options are now present, but feel free anyone to let me know if
I've missed any.

------- Comment #7 From Zach Forrest 2004-10-18 11:15:58 0000 -------
Christian, I think it would make sense to install the gentoo completion script
into /usr/share/bash-completion/ and then make a symlink to it in
/etc/bash_completion.d so as to be consistent with the rest of the optional
packages. Granted, if users modify the script it would get overwritten during
an upgrade as the installation directory isn't config protected. Any thoughts?
Also, would you like me to file a new bug report regarding the latest file
release?

------- Comment #8 From Ciaran McCreesh 2004-10-18 11:42:02 0000 -------
I'm starting to think that a bash-completion-config might be in order...

------- Comment #9 From Aaron Walker (RETIRED) 2004-10-18 16:37:55 0000 -------
> Also, would you like me to file a new bug report regarding the latest file release?

Don't worry about it; I'll release 20040711-r1 first thing in the morning.

> I'm starting to think that a bash-completion-config might be in order...

oohhh, ciaran, do I smell another project?  ;)

------- Comment #10 From Daniel Webert 2004-10-18 18:20:03 0000 -------
plz release/bump direct to the 2004-10-17-version :)

http://freshmeat.net/projects/bashcompletion/?branch_id=20101&release_id=175980

------- Comment #11 From Aaron Walker (RETIRED) 2004-10-19 06:01:24 0000 -------
Thank you Peter for the original completion script.
Thank you Zach for including it and releasing the new version of gentoo-bashcomp.
Thank you Daniel for pointing out the new release.

bash-completion-20041017 will hit cvs in a minute.

Cheers

First Last Prev Next    No search results available      Search page      Enter new bug