diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 564ff05b7..c4556335a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,12 @@ -fish 4.1.2 (released October 07, 2025) -====================================== +fish 4.1.3 (released ???) +========================= + +This release fixes the following regressions identified in 4.1.0: + +- Crash on invalid :doc:`function ` call (:issue:`11912`). + +fish 4.1.2 (released October 7, 2025) +===================================== This release fixes the following regressions identified in 4.1.0: diff --git a/po/de.po b/po/de.po index d7a875256..3e0fdf8cf 100644 --- a/po/de.po +++ b/po/de.po @@ -795,6 +795,10 @@ msgstr "%lsund %lu weitere Zeilen" msgid "%lu\n" msgstr "" +#, c-format +msgid "%ls: function name required" +msgstr "%ls: Brauche Funktionsnamen" + #, c-format msgid "%s" msgstr "" diff --git a/po/en.po b/po/en.po index 8120a7a22..8ea4337a6 100644 --- a/po/en.po +++ b/po/en.po @@ -794,6 +794,10 @@ msgstr "%lsand %lu more rows" msgid "%lu\n" msgstr "" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/fr.po b/po/fr.po index 03cc3567a..b8ff3d2cd 100644 --- a/po/fr.po +++ b/po/fr.po @@ -895,6 +895,10 @@ msgstr "%lset %lu lignes de plus" msgid "%lu\n" msgstr "" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/pl.po b/po/pl.po index 865a3e0e0..fe873cac4 100644 --- a/po/pl.po +++ b/po/pl.po @@ -790,6 +790,10 @@ msgstr "%lsand %lu więcej rzędów" msgid "%lu\n" msgstr "" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index 9fbf5a17e..96436353c 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -795,6 +795,10 @@ msgstr "%lse mais %lu linhas" msgid "%lu\n" msgstr "" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/sv.po b/po/sv.po index e325eac25..3f2e85d5e 100644 --- a/po/sv.po +++ b/po/sv.po @@ -791,6 +791,10 @@ msgstr "%lsoch %lu rader till" msgid "%lu\n" msgstr "" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 01aa7a68b..4677f2879 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -812,6 +812,10 @@ msgstr "%ls还有 %lu 行" msgid "%lu\n" msgstr "%lu\n" +#, c-format +msgid "%ls: function name required" +msgstr "%ls: 函数名称是必须的" + #, c-format msgid "%s" msgstr "%s" diff --git a/src/builtins/function.rs b/src/builtins/function.rs index 687406f7d..18b2d64f1 100644 --- a/src/builtins/function.rs +++ b/src/builtins/function.rs @@ -243,7 +243,19 @@ fn parse_cmd_opts( STATUS_CMD_OK } -fn validate_function_name(function_name: &wstr, cmd: &wstr, streams: &mut IoStreams) -> c_int { +fn validate_function_name( + argv: &mut [&wstr], + function_name: &mut WString, + cmd: &wstr, + streams: &mut IoStreams, +) -> c_int { + if argv.len() < 2 { + streams + .err + .append(wgettext_fmt!("%ls: function name required", cmd)); + return STATUS_INVALID_ARGS; + } + *function_name = argv[1].to_owned(); if !valid_func_name(function_name) { streams.err.append(wgettext_fmt!( "%ls: %ls: invalid function name", @@ -281,8 +293,8 @@ pub fn function( let cmd = argv[0]; // A valid function name has to be the first argument. - let function_name = argv[1].to_owned(); - let mut retval = validate_function_name(&function_name, cmd, streams); + let mut function_name = WString::new(); + let mut retval = validate_function_name(argv, &mut function_name, cmd, streams); if retval != STATUS_CMD_OK { return retval; } diff --git a/tests/checks/function.fish b/tests/checks/function.fish index 2e30e08c7..dafbc6c1e 100644 --- a/tests/checks/function.fish +++ b/tests/checks/function.fish @@ -186,4 +186,10 @@ function foo; echo before; end foo (functions --erase foo) # CHECKERR: error: Unknown function 'foo' +function () +end +# CHECKERR: {{.*}}/tests/checks/function.fish (line {{\d+}}): function: function name required +# CHECKERR: function () +# CHECKERR: ^ + exit 0