mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 10:43:32 +08:00
count -h
should report 1
The count command should not treat any flag specially. Not even `-h` and `--help`. It should simply return a count of the number of arguments it received. Fixes #4189
This commit is contained in:
parent
8cc4639ea6
commit
80df9053b3
|
@ -19,6 +19,7 @@
|
||||||
- `help` can now open the tutorial.
|
- `help` can now open the tutorial.
|
||||||
- `echo -h` now correctly echoes `-h` (#4120).
|
- `echo -h` now correctly echoes `-h` (#4120).
|
||||||
- Stop converting empty elements in MANPATH to "." (#4158). The behavior being changed was introduced in fish 2.6.0.
|
- Stop converting empty elements in MANPATH to "." (#4158). The behavior being changed was introduced in fish 2.6.0.
|
||||||
|
- `count -h` and `count --help` now return one (#4189).
|
||||||
- Added completions for:
|
- Added completions for:
|
||||||
- `as` (#4130).
|
- `as` (#4130).
|
||||||
- `jest` (#4142).
|
- `jest` (#4142).
|
||||||
|
|
|
@ -491,7 +491,7 @@ bool builtin_exists(const wcstring &cmd) { return static_cast<bool>(builtin_look
|
||||||
|
|
||||||
/// Is the command a keyword or a builtin we need to special-case the handling of `-h` and `--help`.
|
/// Is the command a keyword or a builtin we need to special-case the handling of `-h` and `--help`.
|
||||||
static const wcstring_list_t help_builtins({L"for", L"while", L"function", L"if", L"end", L"switch",
|
static const wcstring_list_t help_builtins({L"for", L"while", L"function", L"if", L"end", L"switch",
|
||||||
L"case", L"count", L"printf"});
|
L"case", L"printf"});
|
||||||
static bool cmd_needs_help(const wchar_t *cmd) { return contains(help_builtins, cmd); }
|
static bool cmd_needs_help(const wchar_t *cmd) { return contains(help_builtins, cmd); }
|
||||||
|
|
||||||
/// Execute a builtin command
|
/// Execute a builtin command
|
||||||
|
|
0
tests/count.err
Normal file
0
tests/count.err
Normal file
17
tests/count.in
Normal file
17
tests/count.in
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Validate the behavior of the `count` command.
|
||||||
|
|
||||||
|
echo '# no args'
|
||||||
|
count
|
||||||
|
|
||||||
|
echo '# one args'
|
||||||
|
count x
|
||||||
|
|
||||||
|
echo '# two args'
|
||||||
|
count x y
|
||||||
|
|
||||||
|
echo '# args that look like flags or are otherwise special'
|
||||||
|
count -h
|
||||||
|
count --help
|
||||||
|
count --
|
||||||
|
count -- abc
|
||||||
|
count def -- abc
|
12
tests/count.out
Normal file
12
tests/count.out
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# no args
|
||||||
|
0
|
||||||
|
# one args
|
||||||
|
1
|
||||||
|
# two args
|
||||||
|
2
|
||||||
|
# args that look like flags or are otherwise special
|
||||||
|
1
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
Loading…
Reference in New Issue
Block a user