tech.lgbt is one of the many independent Mastodon servers you can use to participate in the fediverse.
We welcome all marginalized identities. This Mastodon instance is generally for folks who are LGBTQIA+ and Allies with an interest in tech work, academics, or technology in general.

Server stats:

2.9K
active users

Public

Dear #python and #unix hackers,

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

(to make #offpunk compatible with #openbsd 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-

Public

@ploum the first line of grep -V reads "grep (GNU grep) 3.11" for me (on Termux) so probably you could just parse the first line of the version and make your own inferences?

@fdavies93 @ploum that's not going to work if the grep supports color auto, but isn't gnu's

Public

@SRAZKVT @ploum presumably, you just bake some logic about that into your application, which would let you be more intelligent than just running with the flag and checking the exit code, but could require annoying version checking logic (there might be a versioned index of capabilities of UNIX utilities or something out there tho, idk)