~lioploum/offpunk-devel

3 2

grep: unknown option -- color=auto

Dylan D'Silva <dylan@dsilva.email>
Details
Message ID
<D5XQC1ECYEID.3KHOCET4CTSM0@dsilva.email>
DKIM signature
pass
Download raw message
Hello all,

As subject says. OpenBSD grep doesn't support the --color option. Maybe
include a check to see if includes color and if not don't use it.
for example,
[[ $(grep --color=auto 2>/dev/null) ]] && alias grep='grep --color=auto'

Dylan
Details
Message ID
<173278979748.6.4183111089373540154.510928670@ploum.eu>
In-Reply-To
<D5XQC1ECYEID.3KHOCET4CTSM0@dsilva.email> (view parent)
DKIM signature
pass
Download raw message
Le 24 nov 28 09:11, Dylan D'Silva a écrit :
>Hello all,
>
>As subject says. OpenBSD grep doesn't support the --color option. Maybe
>include a check to see if includes color and if not don't use it.
>for example,
>[[ $(grep --color=auto 2>/dev/null) ]] && alias grep='grep --color=auto'
>
>Dylan

Hi Dylan,

This is very interesting as you are the first feedback I have from 
Offpunk on OpenBSD (something I was hoping to see).


This definitely needs to be fixed in opnk..py, line 19. 

I don’t see how to translate your bash check into python (I might be not 
in a good condition to do it now).

Is there someone with an idea about the best way to check for options 
from within Python?


-- 
Ploum - Lionel Dricot

Blog: https://www.ploum.net
Bikepunk: https://bikepunk.fr/
Dylan D'Silva <dylan@dsilva.email>
Details
Message ID
<D5XRHI9HWIXS.23RBB789XHUV@dsilva.email>
In-Reply-To
<173278979748.6.4183111089373540154.510928670@ploum.eu> (view parent)
DKIM signature
pass
Download raw message
Hey Ploum,

How about using subprocess?

import subprocess

results = subprocess.run(["grep", "--color=auto"], check=True)

if results == 0
...
else
...

Dylan

On Thu Nov 28, 2024 at 9:29 PM AEDT, Ploum wrote:
> Le 24 nov 28 09:11, Dylan D'Silva a écrit :
> >Hello all,
> >
> >As subject says. OpenBSD grep doesn't support the --color option. Maybe
> >include a check to see if includes color and if not don't use it.
> >for example,
> >[[ $(grep --color=auto 2>/dev/null) ]] && alias grep='grep --color=auto'
> >
> >Dylan
>
> Hi Dylan,
>
> This is very interesting as you are the first feedback I have from 
> Offpunk on OpenBSD (something I was hoping to see).
>
>
> This definitely needs to be fixed in opnk..py, line 19. 
>
> I don’t see how to translate your bash check into python (I might be not 
> in a good condition to do it now).
>
> Is there someone with an idea about the best way to check for options 
> from within Python?
Details
Message ID
<173288320843.7.18302264115054349957.512440081@ploum.eu>
In-Reply-To
<D5XRHI9HWIXS.23RBB789XHUV@dsilva.email> (view parent)
DKIM signature
pass
Download raw message
Le 24 nov 28 10:06, Dylan D'Silva a écrit :
>Hey Ploum,
>
>How about using subprocess?
>
>import subprocess
>
>results = subprocess.run(["grep", "--color=auto"], check=True)
>
>if results == 0

Should be fixed in the Trunk.

(it was a bit harder than that because, to avoid failing, grep need both 
an argument and a input to parse that should be binary. Thus adding 
input=b"x")
Reply to thread Export thread (mbox)