Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sprintf-like version of --output #9

Closed
petdance opened this issue Mar 26, 2017 · 2 comments
Closed

Add a sprintf-like version of --output #9

petdance opened this issue Mar 26, 2017 · 2 comments
Labels

Comments

@petdance
Copy link
Collaborator

We currently use eval for implementing --output. This is fraught with peril.

Redo --output without eval, and maybe with a sprintf-like formatting system.

@petdance petdance added this to the 2.999_01 milestone Mar 26, 2017
@n1vux
Copy link
Contributor

n1vux commented Mar 26, 2017

@n1vux
Copy link
Contributor

n1vux commented Mar 26, 2017

My additional desire is ability to create KWIC/KWOC index which would be much nicer with sprintf in --output.
(Yes, i'd need a post sort but shell is good at piping to sort.)

for better KWIC/KWOC alignment
ack2 --output can sorta do KWOC/KWIC with evil before/after vars
--output '$&^I$'"'"'^I|| $' # KWOC --output '$^I$&^I$'"'" # pseudo KWIC
but they’re nasty from Shell since must mix quote and dollar
and tabs don’t truly line up if width variation exceeds a tab width
need a sprintf with field-width for real thing …
(Our current ack2 --output "evalmanages to not eval'sprintf("%20s\t%20s\t%20s",$,$&,$'"'"')' which is good for security but foils my KWIC/KWOC plans. Unless I use the eval evil i used to break eval previously.)

Related: should allow and recommend use English; vars be used in --output
(is it already? No. In Ack2, $& works but $MATCH does not. Nor does ${^MATCH} )

Related: need to have a variables available to the sprintf that are Filename and $. relative to filename.

@petdance petdance changed the title Reimplement --output Add a sprintf-like version of --output Jul 23, 2017
@petdance petdance removed this from the 2.999_01 milestone Jul 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants