Opened 10 years ago
Closed 10 years ago
#12333 closed defect (fixed)
Restore --grep and --grepdoc command line options
Reported by: | was | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-5.0 |
Component: | misc | Keywords: | |
Cc: | Merged in: | sage-5.0.beta6 | |
Authors: | Francis Clarke | Reviewers: | William Stein, John Palmieri |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
I just tried one of my *favorite* command line options in Sage-4.8:
$ sage -grep optional |grep gap # and all kinds of other awesome command line stuff
and was very surprised and disappointed that (a) sage -grep
is just gone, and (b) there is no other equivalent command line functionality.
Searching reveals that #12190 removed sage -grep
from sage. You can't just remove functionality without any comment. At a minimum it would have to be deprecated for a year, and should also be discussed on sage-devel.
I'm able to accomplish what I want via
./sage -c "search_src('optional', 'gap')"
However, this requires starting up Sage, which is much slower than the old sage -grep
. I admit that "-grep" wasn't the best command line option name -- search_src would have been better.
The optimal fix for this ticket would be to refactor the code in sage/misc/sagedoc.py (if possible) so it can be imported without importing all Sage, then use it to implement a command line "-search_src", and add back "-grep" with a 1-year deprecation.
Failing that, just revert #12190 for 1 year.
Apply:
- trac_12333_restore_grep_root.patch to the root repo
- trac_12333_restore_grep_scripts.patch to the scripts repo
- trac_12333-documentation.patch to the main Sage library repo
Attachments (4)
Change History (12)
Changed 10 years ago by
comment:1 Changed 10 years ago by
- Status changed from new to needs_review
comment:2 follow-ups: ↓ 3 ↓ 4 Changed 10 years ago by
- Status changed from needs_review to needs_work
Unfortunately, grep --recursive ...
does not work on Solaris or OpenSolaris. These are supported platforms for Sage, so we need another approach.
As far as the banner occurs, maybe it shouldn't be there at all? Set SAGE_BANNER=no
, as in sage -c ...
, to omit it.
Finally, this should be rebased to some beta release of Ssge 5.0: the script sage-sage is no longer there; instead, patch SAGE_ROOT/spkg/bin/sage
.
comment:3 in reply to: ↑ 2 Changed 10 years ago by
Replying to jhpalmieri:
Unfortunately,
grep --recursive ...
does not work on Solaris or OpenSolaris. These are supported platforms for Sage, so we need another approach.
But please keep grep --recursive
for everything but Solaris.
As far as the banner occurs, maybe it shouldn't be there at all? Set
SAGE_BANNER=no
, as insage -c ...
, to omit it.
Agreed.
Finally, this should be rebased to some beta release of Ssge 5.0: the script sage-sage is no longer there; instead, patch
SAGE_ROOT/spkg/bin/sage
.
comment:4 in reply to: ↑ 2 Changed 10 years ago by
- Status changed from needs_work to needs_review
Replying to jhpalmieri:
Unfortunately,
grep --recursive ...
does not work on Solaris or OpenSolaris.
The code in the new trac_12333_restore_grep_scripts.patch should work much more generally. It seems to be no slower than the previous approach.
As far as the banner occurs, maybe it shouldn't be there at all? Set
SAGE_BANNER=no
, as insage -c ...
, to omit it. Finally, this should be rebased to some beta release of Sage 5.0: the script sage-sage is no longer there; instead, patchSAGE_ROOT/spkg/bin/sage
.
The attachment trac_12333_restore_grep_root.patch patches SAGE_ROOT/spkg/bin/sage
, removes the banner, and allows -search_src
as a synonym for -grep
, and -search_doc
for -grepdoc
.
One other modification to earlier behaviour: the grep
option -i
is no longer hard-wired, but it can be restored, as can other options. For example:
$ sage -search_src -il clarke sage/rings/morphism.pyx sage/rings/number_field/number_field.py sage/rings/number_field/number_field_element.pyx sage/rings/number_field/number_field_ideal.py sage/rings/number_field/unit_group.py sage/rings/polynomial/polynomial_element_generic.py
comment:5 follow-up: ↓ 6 Changed 10 years ago by
- Description modified (diff)
- Reviewers set to William Stein, John Palmieri
Looks good, works on sage.math, OS X, OpenSolaris. So there don't seem to be any cross-platform issues.
I'm happy with the two main patches: positive review for those. What do you think of the attached patch for the reference manual?
comment:6 in reply to: ↑ 5 Changed 10 years ago by
- Status changed from needs_review to positive_review
Replying to jhpalmieri:
... What do you think of the attached patch for the reference manual?
Looks good to me, so positive review for the documentation change.
comment:7 Changed 10 years ago by
- Summary changed from Add back functionality that was inadvertantly deleted from Sage to Restore --grep and --grepdoc command line options
comment:8 Changed 10 years ago by
- Merged in set to sage-5.0.beta6
- Resolution set to fixed
- Status changed from positive_review to closed
The patch restore
sage -grep
, andsage -grepdoc
, but uses a new simpler, one-line grep. This has the following advantages:In addition a new header is provided, which doesn't include the irrelevant "Type notebook() ...", and which shows the branch (if it isn't main).