Sua finalidade é fornecer acesso aos vários matchers implementados no GNU grep
de uma forma ou de outra, em particular os correspondentes do AWK que não estão disponíveis de outra forma, provavelmente para fins de teste (consulte bug 16481 que discute a adição dos gawk
e posixawk
correspondentes).
No entanto, atualmente é um buggy, que é o motivo pelo qual está documentado como sendo não documentado :
On Thu, Jan 27, 2005 at 04:06:04PM -0500, Charles Levert wrote:
> The '-X' option, and in particular its use with the "awk" matcher
> ("-X awk") is undocumented.please leave it undocumented.
It doesn't provide any new functionality besides -X awk.
And the implementation of awk regexps is not perfect, I think.
The new GNU regex conatins some means to set AWK style syntax, yes. Yet gawk doesn't use it directly: it parses the regex first.
In particular, awk regexps allow escape sequences \NNN, where NNN is an octal value. So /0/ mathes space. grep -X awk doesn't seem to support this.
I'm afraid that regex.c doesn't support these escape sequences.
We would have to make sure that the regexes are fully compatible with awk regexes before we decided to document (and thus support) this feature.
I think it's not worth the trouble.
Stepan
Um follow-up pediu que o comentário fosse adicionado e forneceu um pouco mais de fundo sobre a opção -X
:
My own inclination is to suggest just removing -X entirely. I suspect it was added by the original author mainly for testing purposes. If it's going to stay in, at least add a comment like this.
/* -X is undocumented on purpose. */
to avoid future discussion of a resolved issue.
Arnold
que Stepan fez pouco depois .