mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
Rename base/dir to basename/dirname
"dir" sounds like it asks "is it a directory".
This commit is contained in:
parent
268a9d8db3
commit
00ed0bfb5d
3 changed files with 27 additions and 28 deletions
|
@ -8,8 +8,8 @@ Synopsis
|
|||
|
||||
::
|
||||
|
||||
path base GENERAL_OPTIONS [PATH...]
|
||||
path dir GENERAL_OPTIONS [PATH...]
|
||||
path basename GENERAL_OPTIONS [PATH...]
|
||||
path dirname GENERAL_OPTIONS [PATH...]
|
||||
path extension GENERAL_OPTIONS [PATH...]
|
||||
path filter GENERAL_OPTIONS [(-v | --invert)] \
|
||||
[-d] [-f] [-l] [-r] [-w] [-x] \
|
||||
|
@ -42,16 +42,16 @@ Some subcommands operate on the paths as strings and so work on nonexistent path
|
|||
|
||||
The following subcommands are available.
|
||||
|
||||
.. _cmd-path-base:
|
||||
.. _cmd-path-basename:
|
||||
|
||||
"base" subcommand
|
||||
--------------------
|
||||
"basename" subcommand
|
||||
---------------------
|
||||
|
||||
::
|
||||
|
||||
path base [(-z | --null-in)] [(-Z | --null-out)] [(-q | --quiet)] [PATH...]
|
||||
path basename [(-z | --null-in)] [(-Z | --null-out)] [(-q | --quiet)] [PATH...]
|
||||
|
||||
``path base`` returns the last path component of the given path, by removing the directory prefix and removing trailing slashes. In other words, it is the part that is not the dirname. For files you might call it the "filename".
|
||||
``path basename`` returns the last path component of the given path, by removing the directory prefix and removing trailing slashes. In other words, it is the part that is not the dirname. For files you might call it the "filename".
|
||||
|
||||
It returns 0 if there was a basename, i.e. if the path wasn't empty or just slashes.
|
||||
|
||||
|
@ -60,16 +60,16 @@ Examples
|
|||
|
||||
::
|
||||
|
||||
>_ path base ./foo.mp4
|
||||
>_ path basename ./foo.mp4
|
||||
foo.mp4
|
||||
|
||||
>_ path base ../banana
|
||||
>_ path basename ../banana
|
||||
banana
|
||||
|
||||
>_ path base /usr/bin/
|
||||
>_ path basename /usr/bin/
|
||||
bin
|
||||
|
||||
>_ path base /usr/bin/*
|
||||
>_ path basename /usr/bin/*
|
||||
# This prints all files in /usr/bin/
|
||||
# A selection:
|
||||
cp
|
||||
|
@ -77,14 +77,14 @@ Examples
|
|||
grep
|
||||
rm
|
||||
|
||||
"dir" subcommand
|
||||
"dirname" subcommand
|
||||
--------------------
|
||||
|
||||
::
|
||||
|
||||
path dir [(-z | --null-in)] [(-Z | --null-out)] [(-q | --quiet)] [PATH...]
|
||||
path dirname [(-z | --null-in)] [(-Z | --null-out)] [(-q | --quiet)] [PATH...]
|
||||
|
||||
``path dir`` returns the dirname for the given path. This is the part before the last "/", discounting trailing slashes. In other words, it is the part that is not the basename (discounting superfluous slashes).
|
||||
``path dirname`` returns the dirname for the given path. This is the part before the last "/", discounting trailing slashes. In other words, it is the part that is not the basename (discounting superfluous slashes).
|
||||
|
||||
It returns 0 if there was a dirname, i.e. if the path wasn't empty or just slashes.
|
||||
|
||||
|
@ -93,13 +93,13 @@ Examples
|
|||
|
||||
::
|
||||
|
||||
>_ path dir ./foo.mp4
|
||||
>_ path dirname ./foo.mp4
|
||||
.
|
||||
|
||||
>_ path dir ../banana
|
||||
>_ path dirname ../banana
|
||||
..
|
||||
|
||||
>_ path dir /usr/bin/
|
||||
>_ path dirname /usr/bin/
|
||||
/usr
|
||||
|
||||
"extension" subcommand
|
||||
|
|
|
@ -449,11 +449,11 @@ static int path_transform(parser_t &parser, io_streams_t &streams, int argc, con
|
|||
}
|
||||
|
||||
|
||||
static int path_base(parser_t &parser, io_streams_t &streams, int argc, const wchar_t **argv) {
|
||||
static int path_basename(parser_t &parser, io_streams_t &streams, int argc, const wchar_t **argv) {
|
||||
return path_transform(parser, streams, argc, argv, wbasename);
|
||||
}
|
||||
|
||||
static int path_dir(parser_t &parser, io_streams_t &streams, int argc, const wchar_t **argv) {
|
||||
static int path_dirname(parser_t &parser, io_streams_t &streams, int argc, const wchar_t **argv) {
|
||||
return path_transform(parser, streams, argc, argv, wdirname);
|
||||
}
|
||||
|
||||
|
@ -687,9 +687,8 @@ static constexpr const struct path_subcommand {
|
|||
const wchar_t **argv); //!OCLINT(unused param)
|
||||
} path_subcommands[] = {
|
||||
// TODO: Which operations do we want?
|
||||
// TODO: "base" or "basename"?
|
||||
{L"base", &path_base},
|
||||
{L"dir", &path_dir},
|
||||
{L"basename", &path_basename},
|
||||
{L"dirname", &path_dirname},
|
||||
{L"extension", &path_extension},
|
||||
{L"filter", &path_filter},
|
||||
{L"is", &path_is},
|
||||
|
|
|
@ -59,17 +59,17 @@ path strip-extension ~/.config
|
|||
echo $status
|
||||
# CHECK: 1
|
||||
|
||||
path base ./foo.mp4
|
||||
path basename ./foo.mp4
|
||||
# CHECK: foo.mp4
|
||||
path base ../banana
|
||||
path basename ../banana
|
||||
# CHECK: banana
|
||||
path base /usr/bin/
|
||||
path basename /usr/bin/
|
||||
# CHECK: bin
|
||||
path dir ./foo.mp4
|
||||
path dirname ./foo.mp4
|
||||
# CHECK: .
|
||||
path base ../banana
|
||||
path basename ../banana
|
||||
# CHECK: banana
|
||||
path base /usr/bin/
|
||||
path basename /usr/bin/
|
||||
# CHECK: bin
|
||||
|
||||
cd $TMPDIR
|
||||
|
|
Loading…
Reference in a new issue