mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-24 02:13:39 +08:00
4ae4ea0169
* New -n flag for string join command. This is an argument that excludes empty result items. Fixes #8351 * New documentation for string-join. The new argument --no-empty was added at string-join manpage. * New completions for the new -n flag for string join. * Remove the documentation of the new -n flag of string join0 The reason to remove this new argument in the join0 is that this flag basically doesn't make any difference in the join0. * Refactor the validation for the string join. The string join command was using the length of the argument, this commit changes the validation to use the empty function. * Revert #4b56ab452 The reason for the revert is thath the build broke on the ubuntu in the Github actions. * Revert #e72e239a1 The reason the compilation on GitHub broke is that the test was weird, it didn't even run it, Common CI systems are typically very very resource-constrained. * Resolve conflicts in the string-join.rst. * Resolve conflicts in the "string-join.rst". commit #1242d0fd7 not fixed all conflicts.
47 lines
1.6 KiB
ReStructuredText
47 lines
1.6 KiB
ReStructuredText
string-join - join strings with delimiter
|
|
=========================================
|
|
|
|
Synopsis
|
|
--------
|
|
|
|
.. BEGIN SYNOPSIS
|
|
|
|
.. synopsis::
|
|
|
|
string join [-q | --quiet] SEP [STRING ...]
|
|
string join0 [-q | --quiet] [STRING ...]
|
|
|
|
.. END SYNOPSIS
|
|
|
|
Description
|
|
-----------
|
|
|
|
.. BEGIN DESCRIPTION
|
|
|
|
``string join`` joins its *STRING* arguments into a single string separated by *SEP*, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise. If ``-n`` or ``--no-empty`` is specified, empty strings are excluded from consideration (e.g. ``string join -n + a b "" c`` would expand to ``a+b+c`` not ``a+b++c``).
|
|
|
|
``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.
|
|
|
|
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.
|
|
|
|
.. END DESCRIPTION
|
|
|
|
Examples
|
|
--------
|
|
|
|
.. BEGIN EXAMPLES
|
|
|
|
::
|
|
|
|
>_ seq 3 | string join ...
|
|
1...2...3
|
|
|
|
# Give a list of NUL-separated filenames to du (this is a GNU extension)
|
|
>_ string join0 file1 file2 file\nwith\nmultiple\nlines | du --files0-from=-
|
|
|
|
# Just put the strings together without a separator
|
|
>_ string join '' a b c
|
|
abc
|
|
|
|
.. END EXAMPLES
|