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

wrong behaviour with single digit keywords #10

Open
alex-bender opened this issue Aug 17, 2015 · 4 comments
Open

wrong behaviour with single digit keywords #10

alex-bender opened this issue Aug 17, 2015 · 4 comments
Assignees
Labels

Comments

@alex-bender
Copy link

$ echo 123 | h 1 2 3
31m132m23

tmux version 1.9.6
zsh version zsh 5.0.7 (x86_64-pc-linux-gnu)

@paoloantinori
Copy link
Owner

Thanks for reporting this. I will dig into this.

The underlying ack support seems to behaves correctly but h does not.

echo abc | ack --flush --passthru --color --color-match=red a | ack --flush --passthru --color --color-match=yellow b

@paoloantinori paoloantinori self-assigned this Aug 19, 2015
@paoloantinori
Copy link
Owner

Interesting. The bug is not with tmux per se but with h and numbers.

This works fine

echo abc | h a b c

This doesn't:

echo 123 | h 1 2 3

The reason for this is that, since h is just a wrapper to build a series of pipes on precedent keyword output, the subsequent interactions will see coming in input also the markup characters, that happen to contain numbers, generating false positives and interleaving the markup.

I think this is more a technical limit of h when asked to highlight single character keywords, in particular numbers.

@paoloantinori paoloantinori changed the title wrong behaviour in tmux wrong behaviour with single digit keywords Aug 26, 2015
@mperry2
Copy link
Contributor

mperry2 commented Jan 16, 2016

You can see it with plain ack as well.

echo 123 | ack --noenv --flush --passthru --color --color-match="bold black on_rgb520" '1' |ack --noenv --flush --passthru --color --color-match="bold red on_rgb025" '2' |ack --noenv --flush --passthru --color --color-match="underline bold rgb520" 3

The ANSI color codes are being rewritten by the subsequent calls to ack. Here's a single call. Notice the additional numbers that are added for the ANSI escape sequences.

$ echo 123 | ack --noenv --flush --passthru --color --color-match="bold black on_rgb520" '1' | xxd
0000000: 1b5b 313b 3330 3b34 383b 353b 3230 386d  .[1;30;48;5;208m
0000010: 311b 5b30 6d32 331b 5b30 6d1b 5b4b 0a    1.[0m23.[0m.[K.

This would probably need to be fixed in ack by adding support for multiple search patterns and color-match values in a single execution.

@EugenDueck
Copy link

Due to issues like this one, problems with overlapping matches, and - given the constraints of bash scripts - a lack of prospect of these issues being fixed at all in hhighlighter, I decided to create my own multi-color grep tool, and I am making it available to everyone who's interested: https://github.com/EugenDueck/colorexp

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

4 participants