Skip to content

Allow escaping dash (-) in CLI command parsing to prevent syntax errors #18507

@pnxtm

Description

@pnxtm

Description:

We are adding a new CLI command that includes a dash (-) in its syntax, but the parser incorrectly interprets it as a range and throws an error.

Example Command:

show interface range (1-10) - (1-10)

This should be valid, but it results in the following error:

cmd_yyerror: FATAL parse error: syntax error, unexpected invalid token, expecting end of file
cmd_yyerror: 1:52-53 of this command definition:
cmd_yyerror: | show interface range (1-10) - (1-10)
cmd_yyerror: |                             ^

Issue:

  • The dash (-) is treated as a range separator, causing conflicts when used as a literal character.
  • There seems to be no clear way to escape it so that it is recognized as a normal character.

Expected Behavior:

There should be a way to allow - as a valid character in command syntax without interfering with range parsing.

Request:

Is there a recommended way to handle this in FRR’s command parsing system? A possible solution could be supporting an escape sequence (e.g., \-) or modifying the parser to differentiate between a range operator and a literal dash.

Any guidance on resolving this would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions