Skip to content

Conversation

@certik
Copy link
Collaborator

@certik certik commented Sep 27, 2024

The test script if_else.sh has incorrect syntax for an if statement:

$ bash if_else.sh
if_else.sh: line 2: syntax error near unexpected token `then'
if_else.sh: line 2: `if [[ $FOO -eq 1 ]] then'

The correct syntax uses ; before then.

Unfortunately this correct syntax does not parse:

Syntax error:   × Failed to parse input
  ╰─▶ Failure to parse at Pos((2, 16))
   ╭────
 1 │ if [[ $FOO -eq 1 ]]; then
   ·                ┬
   ·                ╰── expected TILDE_PREFIX, UNQUOTED_ESCAPE_CHAR, SUB_COMMAND, or EXIT_STATUS
   ╰────
  help: expected TILDE_PREFIX, UNQUOTED_ESCAPE_CHAR, SUB_COMMAND,
        or EXIT_STATUS

The test script `if_else.sh` has incorrect syntax for an if statement:

    $ bash if_else.sh
    if_else.sh: line 2: syntax error near unexpected token `then'
    if_else.sh: line 2: `if [[ $FOO -eq 1 ]] then'

The correct syntax uses `;` before `then`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants