Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[osh/cmd_parse] Produce a more useful error message if a dangling do is detected #1570

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PossiblyAShrub
Copy link
Collaborator

@PossiblyAShrub PossiblyAShrub commented Apr 17, 2023

I was experimenting with producing error messages that try to guess at the user's intent and then produce more specific error messages. In this pr, I've added specific error messaging for errors like the following:

for x in a b c do
  echo $x
done

Before my changes we get the following error message:

        echo $x                                                                                                                               
        ^~~~                                                                                                                                  
test.sh:2: Expected word type Id.KW_Do, got Id.Word_Compound

With my changes:

  for x in a b c do                                                                                                                           
                 ^~                                                                                                                           
test.sh:1: Expected a semi-colon or newline before the "do". 

This PR is more of a proof-of-concept, a more thought out PR might generalize this check to while loops.

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.

None yet

1 participant