Home | Docs | Forums | Lists | Bugs | Planet | Store | GMN | Get Gentoo!
View Bug Activity | Format For Printing | XML | Clone This Bug
Here is a patch which adds --before-context/--after-context options to qgrep: % ./qgrep -Evs -B2 -A1 myconf vim eclass/vim.eclass- eclass/vim.eclass-vim_src_compile() { eclass/vim.eclass: local myconf confrule eclass/vim.eclass- -- eclass/vim.eclass- if [[ "${MY_PN}" == "vim-core" ]] || eclass/vim.eclass- ( [[ "${MY_PN}" == "vim" ]] && use minimal ); then eclass/vim.eclass: myconf="--with-features=tiny \ eclass/vim.eclass- --enable-gui=no \ -- eclass/vim.eclass- fi eclass/vim.eclass- eclass/vim.eclass: myconf="--with-features=huge \ eclass/vim.eclass- --enable-multibyte" eclass/vim.eclass: myconf="${myconf} `use_enable cscope`" eclass/vim.eclass: myconf="${myconf} `use_enable gpm`" eclass/vim.eclass: myconf="${myconf} `use_enable perl perlinterp`" eclass/vim.eclass: myconf="${myconf} `use_enable python pythoninterp`" eclass/vim.eclass: myconf="${myconf} `use_enable ruby rubyinterp`" eclass/vim.eclass- # tclinterp is broken; when you --enable-tclinterp flag, then -- <snip> The patch applies on top of the 7 ones from bug #171374. It also adds various comments in the code, since it was starting to get a bit complicated.
Created an attachment (id=114433) [edit] qgrep-08_add_-A_and_-B_options.patch
Oh, and also this patch makes exit status being 0 when there was some matches, and 1 when there was none. (That's actually because i was in need of such a status variable in the code, and then i've thought it might be useful to return it.)
solar@onyx /var/cvsroot/gentoo-projects/portage-utils $ cvs ci -m '- This commit adds -A/-B options for qgrep (context lines) from TGL bug 172240' ... /var/cvsroot/gentoo-projects/portage-utils/qgrep.c,v <-- qgrep.c new revision: 1.19; previous revision: 1.18
The long options names are a little to long and mess up the display. Options: -[IiHNclLexEsS:B:A:vqChV] -I, --invert-match * Select non-matching lines -i, --ignore-case * Ignore case distinctions -H, --with-filename * Print the filename for each match -N, --with-name * Print the package or eclass name for each match -c, --count * Only print a count of matching lines per FILE -l, --list * Only print FILE names containing matches -L, --invert-list * Only print FILE names containing no match -e, --regexp * Use PATTERN as a regular expression -x, --extended * Use PATTERN as an extended regular expression -E, --eclass * Search in eclasses instead of ebuilds -s, --skip-comments * Skip comments lines -S, --skip <arg> * Skip lines matching <arg> -B, --before-context <arg> * Print <arg> lines of leading context -A, --after-context <arg> * Print <arg> lines of trailing context -v, --verbose * Make a lot of noise -q, --quiet * Tighter output; suppress warnings -C, --nocolor * Don't output color -h, --help * Print this help and exit -V, --version * Print version and exit ----------------------------------------- How about we shorten them to --before/--after ? Granted we can make the alignments wider but I'd like to keep the display short and to the point when using a console size of 23 79
Created an attachment (id=114536) [edit] qgrep-context-names.diff Shortened names. (pending your input). After this it's probably about time for us to push a new portage-utils to the tree.
(In reply to comment #4) > > How about we shorten them to --before/--after ? Yup, sure, go ahead. Your patch looks good (and i've checked it was exhaustive). (In reply to comment #5) > > After this it's probably about time for us to push a new > portage-utils to the tree. Can you wait just a sec? I have one more patch ready, for which i was about to open a new report. It adds an option for grepping in the ebuilds stored in VDB. (And then there will still be colorized output left on my TODO, but for this one i will have to find more time, so don't hold your breath or release.)
(In reply to comment #5) > Created an attachment (id=114536) [edit] > qgrep-context-names.diff > > Shortened names. (pending your input). After this it's probably about time for > us to push a new portage-utils to the tree. /var/cvsroot/gentoo-projects/portage-utils/qgrep.c,v <-- qgrep.c new revision: 1.20; previous revision: 1.19
This is released in 0.1.25 Bug #168334 ; q -r dies with a segfault after emerge --sync Bug #168442 ; does not properly parse the profile location Bug #170795 ; add a -E/--eclass option to qgrep Bug #170797 ; add a -s/--skip-comments option to qgrep Bug #171024 ; opening '/usr/portage/.metadata.x' failed Bug #171374 ; Misc enhancements for qgrep Bug #172240 ; -A/-B options for qgrep (context lines) Bug #172338 ; qgrepping through installed ebuilds (in the VDB) Bug #173005 ; Colorized output for qgrep.
Closing