You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're living in the age of the markdown backtick. Let's embrace it in Nix.
Proposal
Change all '%s' and '%1%' to `%s` and `%1%`
Effects
(+) Clear, visually unambiguous stderr output
(+) Renders into inline code spans when pasted into a markdown system such as GitHub, Discourse, etc
(-) Slightly more typing when discussing the C++ code in markdown
Try with ``"`%s`"``
Use a backtick (`` ` ``)
renders to
Try with "`%s`"
Use a backtick (`)
Background
Nix uses ' apostrophes to demarcate the start and end of code, identifiers, user input, etc, in error messages.
This is occasionally confusing:
color information is not always available, including after copy/paste (i.e. when users need help)
adds visual noise
can be confused for the same ' that is allowed in identifiers, moderately obscuring the difference between 'mapAttrs' and 'mapAttrs''
Meanwhile, I have observed that over the past decade or so:
` has been largely phased out from bash scripts in favor of $( )
markdown has won
the markdown ` is starting to make its way into stderr
If we were to switch from 'foo' to `foo` in error messages, this will avoid any confusing with the ' used in the language, and it will even render nicely when pasted into markdown-based systems.
The text was updated successfully, but these errors were encountered:
Generally in favor of this. Ideally we would have the Error constructor making sure that string arguments are properly escaped so they can actually be rendered as Markdown in the terminal. E.g. instead of
throw BadStorePath("path '%1%' is not in the Nix store", path);
do
throw BadStorePath("path %s is not in the Nix store", path);
where the Error constructor would take care of adding backticks around string arguments and escaping any backtick characters in the string. (Worth noting that std::filesystem::path already automatically gets quoted in format strings.)
Also, while we're at it, I'd like to start capitalizing/punctuating errors properly, i.e.
throw BadStorePath("Path %s is not in the Nix store.", path);
We're living in the age of the markdown backtick. Let's embrace it in Nix.
Proposal
Change all
'%s'
and'%1%'
to`%s`
and`%1%`
Effects
Try with
"`%s`"
Use a backtick (
`
)Background
Nix uses
'
apostrophes to demarcate the start and end of code, identifiers, user input, etc, in error messages.This is occasionally confusing:
'
that is allowed in identifiers, moderately obscuring the difference between'mapAttrs'
and'mapAttrs''
Meanwhile, I have observed that over the past decade or so:
`
has been largely phased out from bash scripts in favor of$( )
`
is starting to make its way into stderrIf we were to switch from
'foo'
to`foo`
in error messages, this will avoid any confusing with the'
used in the language, and it will even render nicely when pasted into markdown-based systems.The text was updated successfully, but these errors were encountered: