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

[BUG] Postprocessor failure is not detected #571

Closed
hdwalters opened this issue Nov 9, 2024 · 0 comments · Fixed by #572
Closed

[BUG] Postprocessor failure is not detected #571

hdwalters opened this issue Nov 9, 2024 · 0 comments · Fixed by #572
Assignees
Labels
bug Something isn't working

Comments

@hdwalters
Copy link
Contributor

hdwalters commented Nov 9, 2024

Describe the bug
If a postprocessor returns a non-zero (error) exit code, it is not detected, and the empty standard output is returned instead.

To Reproduce
To reproduce this, create an Amber script with an unterminated if statement inside $...$ delimiters:

hwalters@Ghostwheel ~/git/amber-lang (master) 
$ cat failing.ab 
trust $ if $

We can confirm that shfmt rejects this invalid Bash as follows:

hwalters@Ghostwheel ~/git/amber-lang (master) 
$ shfmt <<EOF
> if
> EOF
<standard input>:1:1: "if <cond>" must be followed by "then"

However, when the Amber script is compiled to Bash, the postprocessor ignores the shfmt error:

hwalters@Ghostwheel ~/git/amber-lang (master) 
$ amber failing.ab -
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.3.5-alpha
# date: 2024-11-09 22:14:43

Expected behavior
Amber should show the contents of the standard error stream returned by the postprocessor:

hwalters@Ghostwheel ~/git/amber-lang (master) 
$ amber failing.ab -
 ERROR  Postprocessor 'shfmt' failed
<standard input>:1:1: "if <cond>" must be followed by "then"

Additional context
This is happening because the ExitStatus (returned by the Child subprocess in the postprocessor code) is not checked for success. It will also be necessary to propagate the error result back up the call chain.

@hdwalters hdwalters added the bug Something isn't working label Nov 9, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Nov 9, 2024
@hdwalters hdwalters self-assigned this Nov 9, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to 🏁 Done in Amber Project Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant