Add sort --unique

This commit is contained in:
Fabian Homborg
2022-04-26 21:10:54 +02:00
parent 54778f65f8
commit c88f648cdf
3 changed files with 47 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ Synopsis
path resolve GENERAL_OPTIONS [PATH...]
path change-extension GENERAL_OPTIONS EXTENSION [PATH...]
path sort GENERAL_OPTIONS [(-v | --invert)] \
[--what=basename|dirname|path] [([PATH...]
[-u | --unique] [--what=basename|dirname|path] [([PATH...]
GENERAL_OPTIONS := [(-z | --null-in)] [(-Z | --null-out)] [(-q | --quiet)]
@@ -351,6 +351,8 @@ With ``--invert`` or ``-v`` the sort is reversed.
With ``--what=`` only the given path of the path is compared, e.g. ``--what=dirname`` causes only the dirname to be compared, ``--what=basename`` only the basename and ``--what=path`` causes the entire path to be compared (this is the default).
With ``--unique`` or ``-u`` the sort is deduplicated, meaning only the first of a run that have the same key is kept. So if you are sorting by basename, then only the first of each basename is used.
The sort used is stable, so sorting first by basename and then by dirname works and causes the files to be grouped according to directory.
It currently returns 0 if it was given any paths.
@@ -368,6 +370,10 @@ Examples
10-foo
2-bar
>_ path sort --unique --what=basename $fish_function_path/*.fish
# prints a list of all function files fish would use, sorted by name.
Combining ``path``
-------------------