8000 Improve docs for `string join` by danielrainer · Pull Request #11506 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Improve docs for string join #11506

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

Merged
merged 1 commit into from
May 29, 2025

Conversation

danielrainer
Copy link

Fixes issue #11478


``string join0`` joins its *STRING* arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``. Exit status: 0 if at least one join was performed, or 1 otherwise.
``-n`` or ``--no-empty``: Exclude empty strings from consideration (e.g. ``string join -n + a b "" c`` would expand to ``a+b+c`` not ``a+b++c``).
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we have this "list" style anywhere else?
I know it's common in man pages but we probably use full-sentences everywhere.
But the added whitespace seems to make it easier to read, so this looks good.

Copy link
Author
@danielrainer danielrainer May 27, 2025

Choose a reason for hiding this comment

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

Yes, this style does not seem to be commonly used in the fish docs. I like this style because it makes it easier to find the description of a particular flag, which is reinforced by this style being so common in other man pages.

Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution <expand-command-substitution>`) won't actually work. Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends. This is a limitation of Unix' argument passing.
``-q`` or ``--quiet``: Do not print the strings, only set the exit status as described above.

**WARNING**: If you omit the ``--`` before the strings to be joined, any strings starting with
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if the first letter after a colon is usually capitalized in English.
Not sure what our convention is but lowercase "If" would be my preference.
Our commit log is inconsistent..

same applies elsewhere in this patch

Copy link
Author

Choose a reason for hiding this comment

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

It seems that capitalization of a complete sentence following a colon is mostly a stylistic choice in English. I think it makes sense to capitalize complete sentences, but it's something that I consider not particularly relevant.

Another option would be to drop the semicolons and use some means of formatting to separate the flags from their description. Not sure how well that would work in rst.

Copy link
Author

Choose a reason for hiding this comment

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

I switched to the format commonly found in man pages. The docs for the complete command do something similar. Instead of separating short and long options with or, I use a comma, as this seems to be the style used in most man pages. This also works better with certain man page viewers. E.g. the viewer built into nvim colors the options correctly when separated by commas, but not when using or instead.

failing.
This is also true if you specify a variable which expands to such a string instead of a literal string.
If you don't need to append flag arguments at the end of the command,
just always use ``--`` to avoid unwelcome surprises.
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a general problem but yeah, it's probably fine to include it here more prominently

@danielrainer danielrainer force-pushed the improve_string_join_docs branch from 3c7410c to e2b69e2 Compare May 27, 2025 13:53
@danielrainer danielrainer force-pushed the improve_string_join_docs branch from e2b69e2 to ec8fa74 Compare May 28, 2025 15:09
@krobelus krobelus added this to the fish 4.1 milestone May 29, 2025
@krobelus krobelus merged commit 19c3beb into fish-shell:master May 29, 2025
7 of 8 checks passed
@zanchey zanchey added the docs An issue/PR that touches or should touch the docs label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs An issue/PR that touches or should touch the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0