Skip to content

Conversation

@schneems
Copy link
Collaborator

Mirroring the behavior from ruby -wc the command line now returns non-zero exit codes when it finds a syntax error:

$ ruby -wc /tmp/scratch.rb
/tmp/scratch.rb:3: syntax error, unexpected `end', expecting ']'
$ echo $?
1

New behavior:

$ ./exe/dead_end /tmp/scratch.rb

DeadEnd: Unmatched `]` detected

file: /tmp/scratch.rb
simplified:

      1  def foo
    ❯ 2    foo = [ 1,1,1
      3  end

$ echo $?
1

The alternative to this logic would be to return 0 for all cases unless an internal error happens.

This change will allow the vscode extension to use an exit code rather than relying on output strings https://github.com/zombocom/dead_end-vscode/blob/2f2560a073c93015e05d0baab0bf5e2853866e0f/extension.js#L16.

Mirroring the behavior from `ruby -wc` the command line now returns non-zero exit codes when it finds a syntax error:

```
$ ruby -wc /tmp/scratch.rb
/tmp/scratch.rb:3: syntax error, unexpected `end', expecting ']'
$ echo $?
1
```

New behavior:

```
$ ./exe/dead_end /tmp/scratch.rb

DeadEnd: Unmatched `]` detected

file: /tmp/scratch.rb
simplified:

      1  def foo
    ❯ 2    foo = [ 1,1,1
      3  end

$ echo $?
1
```

The alternative to this logic would be to return 0 for all cases unless an internal error happens. 

This change will allow the vscode extension to use an exit code rather than relying on output strings https://github.com/zombocom/dead_end-vscode/blob/2f2560a073c93015e05d0baab0bf5e2853866e0f/extension.js#L16.
@schneems schneems force-pushed the schneems/exe-exit-code branch from 2fc40e8 to 3b69591 Compare October 13, 2021 14:06
@schneems schneems requested a review from mauro-oto October 13, 2021 14:06
@schneems schneems marked this pull request as ready for review October 13, 2021 14:08
Copy link
Contributor

@mauro-oto mauro-oto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schneems this is great! 👏

@schneems schneems merged commit 698e178 into main Oct 13, 2021
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.

3 participants