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

Use stdout only for literal text of trusted content #21

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

Conversation

charles-dyfis-net
Copy link
Contributor

Per POSIX conventions, stdout is for "conventional output", whereas stderr is for "diagnostic output". Diagnostic output is conventionally interpreted to include logs, status messages, prompts, or other content of interest to human operators, such that stdout can be directed through pipelines or redirections for programmatic consumption while stderr is routed directly to the human operator.

  • When we are asked to verify a document and write that document to stdout, write only the document (not verification messages, not the trusted comment text) to stdout.
  • When we are asked to verify a document and write only the trusted comment, that comment is our "conventional output" -- the thing we were invoked to generate -- and should be written to stdout without any prelude, header, explanatory content, etc.
  • In modes where we aren't being invoked with the intention of generating some kind of well-defined output on stdout, keep all interaction on stderr to avoid potential for confusion.

-Q is modified from "pretty quiet" to instead be a directive to write the literal text of the trusted comment to stdout; this provides a programmatic way to retrieve that comment that doesn't require filtering/modifying output to separate the literal text from the explanatory prose.

Per POSIX conventions, stdout is for "conventional output", whereas stderr is for "diagnostic output". Diagnostic output is conventionally interpreted to include logs, status messages, prompts, or other content of interest to human operators, such that stdout can be directed through pipelines or redirections for programmatic consumption while stderr is routed directly to the human operator.

- When we are asked to verify a document and write that document to stdout, write _only_ the document (not verification messages, not the trusted comment text) to stdout.
- When we are asked to verify a document and write only the trusted comment, that comment is our "conventional output" -- the thing we were invoked to generate -- and should be written to stdout without any prelude, header, explanatory content, etc.
- In modes where we aren't being invoked with the intention of generating some kind of well-defined output on stdout, keep _all_ interaction on stderr to avoid potential for confusion.

`-Q` is modified from "pretty quiet" to instead be a directive to write the literal text of the trusted comment to stdout; this provides a programmatic way to retrieve that comment that doesn't require filtering/modifying output to separate the literal text from the explanatory prose.
@charles-dyfis-net
Copy link
Contributor Author

I think there's a bug in here -- getting an extra CRLF on stderr and signatures generated on stdout without a trailing newline. Withdrawing to draft for now.

@charles-dyfis-net charles-dyfis-net marked this pull request as draft January 5, 2023 18:04
@charles-dyfis-net
Copy link
Contributor Author

On further investigation, that trailing-newline delta is present on main without this PR merged; it's thus not a new bug. Reopening.

@charles-dyfis-net charles-dyfis-net marked this pull request as ready for review January 5, 2023 18:19
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.

1 participant