diff --git a/CHANGELOG.md b/CHANGELOG.md index da0bc3665..7308caa50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ This section is for changes merged to the `major` branch that are not also merge - `alias` now has a `-s` and `--save` option to save the function generated by the alias using `funcsave` (#4878). - Path completions now support expansions, meaning expressions like `python ~/` now provides file suggestions just like any other relative or absolute path. (This includes support for other expansions, too.) - The `string` builtin has new commands `split0` and `join0` for working with NUL-delimited output. +- The `-d` option to `functions` to set the description of an existing function now works; before 3.0 it was documented but unimplemented. Note that the long form `--description` continues to work. (#5105) ## Other significant changes - Command substitution output is now limited to 10 MB by default (#3822). diff --git a/src/builtin_functions.cpp b/src/builtin_functions.cpp index dd6d10d76..4f273840c 100644 --- a/src/builtin_functions.cpp +++ b/src/builtin_functions.cpp @@ -39,7 +39,7 @@ struct functions_cmd_opts_t { wchar_t *handlers_type = NULL; wchar_t *description = NULL; }; -static const wchar_t *short_options = L":HDacehnqv"; +static const wchar_t *short_options = L":HDacd:ehnqv"; static const struct woption long_options[] = { {L"erase", no_argument, NULL, 'e'}, {L"description", required_argument, NULL, 'd'}, {L"names", no_argument, NULL, 'n'}, {L"all", no_argument, NULL, 'a'}, diff --git a/tests/functions.in b/tests/functions.in index d1eae6e64..2275a2a90 100644 --- a/tests/functions.in +++ b/tests/functions.in @@ -60,3 +60,17 @@ set x (functions -v -D multiline_descr) if test $x[5] != 'line 1\\\\n\\nline 2 & more; way more' echo "Unexpected output for 'functions -v -D multiline_descr': $x" >&2 end + +# ========== +# Verify function description setting +function test_func_desc ; end +functions test_func_desc | string match --quiet '*description*' +and echo "Unexpected description" >&2 + +functions --description description1 test_func_desc +functions test_func_desc | string match --quiet '*description1*' +or echo "Failed to find description 1" >&2 + +functions -d description2 test_func_desc +functions test_func_desc | string match --quiet '*description2*' +or echo "Failed to find description 2" >&2