diff mbox

[1/3] scanner: replace binary characters '&' '|' and '!' by their names

Message ID 1389699030-6301-2-git-send-email-pablo@netfilter.org
State Superseded
Headers show

Commit Message

Pablo Neira Ayuso Jan. 14, 2014, 11:30 a.m. UTC
These symbol need to be escaped in bash and can lead to confusion,
so let's use their names instead which are still short, eg.

 nft add rule filter output meta mark and 0x3 == 0x1

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/scanner.l |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Pablo Neira Ayuso Jan. 14, 2014, noon UTC | #1
On Tue, Jan 14, 2014 at 12:30:28PM +0100, Pablo Neira Ayuso wrote:
> These symbol need to be escaped in bash and can lead to confusion,
> so let's use their names instead which are still short, eg.
> 
>  nft add rule filter output meta mark and 0x3 == 0x1
> 
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  src/scanner.l |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/scanner.l b/src/scanner.l
> index cee6aa6..2d7ac88 100644
> --- a/src/scanner.l
> +++ b/src/scanner.l
> @@ -200,9 +200,9 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
>  "<<"			{ return LSHIFT; }
>  ">>"			{ return RSHIFT; }
>  "^"			{ return CARET; }

Extending this proposal:

For consistency, we can also rename the caret to 'xor'.

Regarding <<, we can use lshift, but that's a bit longer.

We also have >, >=, < and <=. We could use gt, ge, lt, le.

> -"&"			{ return AMPERSAND; }
> -"|"			{ return '|'; }
> -"!"			{ return NOT; }
> +"and"			{ return AMPERSAND; }
> +"or"			{ return '|'; }
> +"not"			{ return NOT; }
>  "/"			{ return SLASH; }
>  "-"			{ return DASH; }
>  "*"			{ return ASTERISK; }
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Patrick McHardy Jan. 14, 2014, 12:21 p.m. UTC | #2
On Tue, Jan 14, 2014 at 12:30:28PM +0100, Pablo Neira Ayuso wrote:
> These symbol need to be escaped in bash and can lead to confusion,
> so let's use their names instead which are still short, eg.
> 
>  nft add rule filter output meta mark and 0x3 == 0x1

Seems fine to me, although I'd rather have both ways of specifying them.

> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  src/scanner.l |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/scanner.l b/src/scanner.l
> index cee6aa6..2d7ac88 100644
> --- a/src/scanner.l
> +++ b/src/scanner.l
> @@ -200,9 +200,9 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
>  "<<"			{ return LSHIFT; }
>  ">>"			{ return RSHIFT; }
>  "^"			{ return CARET; }
> -"&"			{ return AMPERSAND; }
> -"|"			{ return '|'; }
> -"!"			{ return NOT; }
> +"and"			{ return AMPERSAND; }
> +"or"			{ return '|'; }
> +"not"			{ return NOT; }
>  "/"			{ return SLASH; }
>  "-"			{ return DASH; }
>  "*"			{ return ASTERISK; }
> -- 
> 1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Patrick McHardy Jan. 14, 2014, 12:24 p.m. UTC | #3
On Tue, Jan 14, 2014 at 01:00:57PM +0100, Pablo Neira Ayuso wrote:
> On Tue, Jan 14, 2014 at 12:30:28PM +0100, Pablo Neira Ayuso wrote:
> > These symbol need to be escaped in bash and can lead to confusion,
> > so let's use their names instead which are still short, eg.
> > 
> >  nft add rule filter output meta mark and 0x3 == 0x1
> > 
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > ---
> >  src/scanner.l |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/scanner.l b/src/scanner.l
> > index cee6aa6..2d7ac88 100644
> > --- a/src/scanner.l
> > +++ b/src/scanner.l
> > @@ -200,9 +200,9 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
> >  "<<"			{ return LSHIFT; }
> >  ">>"			{ return RSHIFT; }
> >  "^"			{ return CARET; }
> 
> Extending this proposal:
> 
> For consistency, we can also rename the caret to 'xor'.
> 
> Regarding <<, we can use lshift, but that's a bit longer.
> 
> We also have >, >=, < and <=. We could use gt, ge, lt, le.

Agreed on all of those, but please also keep the short forms.

> > -"&"			{ return AMPERSAND; }
> > -"|"			{ return '|'; }
> > -"!"			{ return NOT; }
> > +"and"			{ return AMPERSAND; }
> > +"or"			{ return '|'; }
> > +"not"			{ return NOT; }
> >  "/"			{ return SLASH; }
> >  "-"			{ return DASH; }
> >  "*"			{ return ASTERISK; }
> > -- 
> > 1.7.10.4
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/scanner.l b/src/scanner.l
index cee6aa6..2d7ac88 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -200,9 +200,9 @@  addrstring	({macaddr}|{ip4addr}|{ip6addr})
 "<<"			{ return LSHIFT; }
 ">>"			{ return RSHIFT; }
 "^"			{ return CARET; }
-"&"			{ return AMPERSAND; }
-"|"			{ return '|'; }
-"!"			{ return NOT; }
+"and"			{ return AMPERSAND; }
+"or"			{ return '|'; }
+"not"			{ return NOT; }
 "/"			{ return SLASH; }
 "-"			{ return DASH; }
 "*"			{ return ASTERISK; }