Gorka Guardiola
2012-06-14 08:28:09 UTC
While playing with grep, I was suprised by grep '*\.c' not giving
an error (* is missing an operand). Arguably * applied to empty
can match empty, but surprisingly enough, Acme's edit behaves
differently. And even grep is not consistent (grep '*' is different than
grep '' whereas both should be an empty pattern or the first one
should be an error). Another funny one is that Edit gives back
an error complaining of missing operand to * when the regexp is
empty.
Greps from other systems accept an empty pattern
(and are thus consistent but they would not have
catched the error starting all this).
cpu% echo hola | grep '*a'
hola
cpu% echo hola | grep '*'
grep: *: syntax error
cpu% echo hola | grep ''
grep: empty pattern
Edit , s/*//
regexp: missing operand for *
Edit: bad regexp in s command
Edit , s/*c//
regexp: missing operand for *
Edit: bad regexp in s command
Edit , s///
regexp: missing operand for *
Edit: bad regexp in s command
G.
an error (* is missing an operand). Arguably * applied to empty
can match empty, but surprisingly enough, Acme's edit behaves
differently. And even grep is not consistent (grep '*' is different than
grep '' whereas both should be an empty pattern or the first one
should be an error). Another funny one is that Edit gives back
an error complaining of missing operand to * when the regexp is
empty.
Greps from other systems accept an empty pattern
(and are thus consistent but they would not have
catched the error starting all this).
cpu% echo hola | grep '*a'
hola
cpu% echo hola | grep '*'
grep: *: syntax error
cpu% echo hola | grep ''
grep: empty pattern
Edit , s/*//
regexp: missing operand for *
Edit: bad regexp in s command
Edit , s/*c//
regexp: missing operand for *
Edit: bad regexp in s command
Edit , s///
regexp: missing operand for *
Edit: bad regexp in s command
G.