diff --git a/CHANGELOG.md b/CHANGELOG.md index d542ff657..6a5ee319b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - `help` can now open the tutorial. - `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. +- `count -h` and `count --help` now return one (#4189). - Added completions for: - `as` (#4130). - `jest` (#4142). diff --git a/src/builtin.cpp b/src/builtin.cpp index fa2e0376f..2ffc017e3 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -491,7 +491,7 @@ bool builtin_exists(const wcstring &cmd) { return static_cast(builtin_look /// 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", - L"case", L"count", L"printf"}); + L"case", L"printf"}); static bool cmd_needs_help(const wchar_t *cmd) { return contains(help_builtins, cmd); } /// Execute a builtin command diff --git a/tests/count.err b/tests/count.err new file mode 100644 index 000000000..e69de29bb diff --git a/tests/count.in b/tests/count.in new file mode 100644 index 000000000..683c54a69 --- /dev/null +++ b/tests/count.in @@ -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 diff --git a/tests/count.out b/tests/count.out new file mode 100644 index 000000000..ca42bee04 --- /dev/null +++ b/tests/count.out @@ -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