pkl format should not exit with 11 in case of violation found #365

Closed
opened 2025-12-30 01:23:51 +01:00 by adam · 3 comments
Owner

Originally created by @StefMa on GitHub (Nov 18, 2025).

I'm not an CLI nor an exit code expert.
But when I run pkl format -w . I realize that it exit with 11 (violation found).
This is also documented:

Image

However, I think a CLI should only return non zero in case of an error in the process.
It should not return non zero in case the CLI (format) tool runs successfully, but found problems.

Looking also into wikipedia about Exit status:

For the shell's purposes, a command which exits with a zero exit status has succeeded. A nonzero exit status indicates failure.

For me it sounds like "a non exit code means the program doesn't behave correctly, failed for some reaasons".
But it is not! It just found violation errors. This is his job 🤷 😁

What do you think?

Originally created by @StefMa on GitHub (Nov 18, 2025). I'm not an CLI nor an exit code expert. But when I run `pkl format -w .` I realize that it exit with 11 (violation found). This is also documented: <img width="809" height="373" alt="Image" src="https://github.com/user-attachments/assets/f7e7a289-5358-4a5b-b4d8-c6a1f86a89e3" /> However, I think a CLI should only return non zero in case of an **error in the process**. It should not return non zero in case the CLI (format) tool runs successfully, but found problems. Looking also into wikipedia about [Exit status](https://en.wikipedia.org/wiki/Exit_status): > For the shell's purposes, a command which exits with a zero exit status has succeeded. A nonzero exit status indicates failure. For me it sounds like "a non exit code means the program doesn't behave correctly, failed for some reaasons". But it is not! It just found violation errors. This is his job 🤷 😁 What do you think?
adam closed this issue 2025-12-30 01:23:51 +01:00
Author
Owner

@thejcannon commented on GitHub (Dec 3, 2025):

Looking at other file formatters:

Tool Check bad Check good Overwrite Bad Overwrite Good
Python's ruff format
(ruff format --check and ruff format)
1 0 0 0
Go's gofmt
(gofmt -d and gofmt -w)
0 0 0 0
Shell shfmt
(shfmt -d and shfmt -w)
1 0 0 0
Rust's rustfmt
(rustfmt --check and rustfmt)
1 0 0 0
YAML's yamlfmt
(yamlfmt -lint and yamlfmt)
1 0 0 0
TOML's taplo format
(taplo format --check and taplo format)
1 0 0 0
PKL's pkl format
(pkl format --diff-name-only and pkl format -w)
11 0 11 0
@thejcannon commented on GitHub (Dec 3, 2025): Looking at other file formatters: | Tool | Check bad | Check good | Overwrite Bad | Overwrite Good | |--------|--------|--------|--------|--------| | Python's `ruff format`<br/>(`ruff format --check` and `ruff format`) | 1 | 0 | 0 | 0 | | Go's `gofmt`<br/>(`gofmt -d` and `gofmt -w`) | 0 | 0 | 0 | 0 | | Shell `shfmt`<br/>(`shfmt -d` and `shfmt -w`) | 1 | 0 | 0 | 0 | | Rust's `rustfmt`<br/>(`rustfmt --check` and `rustfmt`) | 1 | 0 | 0 | 0 | | YAML's `yamlfmt`<br/>(`yamlfmt -lint` and `yamlfmt`) | 1 | 0 | 0 | 0 | | TOML's `taplo format`<br/>(`taplo format --check` and `taplo format`) | 1 | 0 | 0 | 0 | | PKL's `pkl format`<br/>(`pkl format --diff-name-only` and `pkl format -w`) | 11 | 0 | 11 | 0 |
Author
Owner

@bioball commented on GitHub (Dec 3, 2025):

@thejcannon thanks for the comparison! I'm convinced that we should just change this.

@bioball commented on GitHub (Dec 3, 2025): @thejcannon thanks for the comparison! I'm convinced that we should just change this.
Author
Owner

@thejcannon commented on GitHub (Dec 6, 2025):

Thanks for the quick update. ♥️

@thejcannon commented on GitHub (Dec 6, 2025): Thanks for the quick update. ♥️
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#365