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

Output from "source" unclear on parse error #25

Closed
lheckemann opened this issue Aug 5, 2017 · 3 comments
Closed

Output from "source" unclear on parse error #25

lheckemann opened this issue Aug 5, 2017 · 3 comments

Comments

@lheckemann
Copy link
Contributor

Given a script foo.sh which osh cannot parse, source foo.sh gives much less helpful information than osh foo.sh, simply outputting the contents of the script rather than describing the errors.

$ cat foo.sh
declare -a foo
$ result/bin/osh -c 'source foo.sh'
Error parsing code 'declare -a foo\n'
$ result/bin/osh foo.sh
Line 1 of 'foo.sh'
  declare -a foo
          ^~
Invalid variable name '-a'
---
Line 0 of '<unknown>'
  <no position info for token>
Error parsing AndOr in ParseCommandTerm
---
@andychu
Copy link
Contributor

andychu commented Aug 6, 2017

Thanks for the bug reports! Keep them coming.

I just fixed the first two but this one might take a little longer.

There are two bugs here:

  1. declare -a shouldn't be parsed statically, or it should handle the -a flag correctly
  2. the error message should be better, as you point out

@andychu
Copy link
Contributor

andychu commented Aug 7, 2017

OK I fixed the error messages in:

d422565

Example:

$ bin/osh -c 'source bad.sh'
osh error: Parse error in 'bad.sh':
Line 1 of 'bad.sh'
  echo >
        ^
Expected word after redirect operator
---

There's still work to do on this, but I'll track it in issue #26 and issue #27.

Thanks for the report!

@andychu andychu closed this as completed Aug 7, 2017
@lheckemann
Copy link
Contributor Author

Thanks!

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

No branches or pull requests

2 participants