mamot.fr is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mamot.fr est un serveur Mastodon francophone, géré par La Quadrature du Net.

Server stats:

3.5K
active users

Dear and hackers,

I’m trying to find out, in Python, if "grep" has the option "--color=auto" or not.

(to make compatible with grep )

Any suggestion? (the one on the mailing-list doesn’t work for me)

I could simply scan "grep --help" for the option but, intuitively, I don’t like it.

lists.sr.ht/~lioploum/offpunk-

b'color' in open('/bin/grep','rb').read() ?

ploum

@tnt : that’s quite error prone (need to check the path).

I managed to do it by checking for "x" in the binary stream b'x' with the color option. If it fails, fallback to grep without color. (the challenge was to ensure that the grep test would succeed)

git.sr.ht/~lioploum/offpunk/co