From b7fe3190bba1e7d314d3b4e65000f9cd8b6d6e38 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 8 Oct 2025 10:30:35 +0200 Subject: [PATCH] Revert "builtin function: remove dead code" This reverts commit 993b977c9b1d730c66c132b875e7e0db122e881d. Fixes #11912 --- CHANGELOG.rst | 7 +++++++ po/de.po | 4 ++++ po/en.po | 4 ++++ po/fr.po | 4 ++++ po/pl.po | 4 ++++ po/pt_BR.po | 4 ++++ po/sv.po | 4 ++++ po/zh_CN.po | 4 ++++ src/builtins/function.rs | 18 +++++++++++++++--- tests/checks/function.fish | 6 ++++++ 10 files changed, 56 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f16d75c5b..dbbc1797c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,13 @@ fish ?.?.? (released ???) ========================= +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) ===================================== diff --git a/po/de.po b/po/de.po index c19042ba2..7de05fed7 100644 --- a/po/de.po +++ b/po/de.po @@ -82,6 +82,10 @@ msgstr "$status ist kein gültiger Befehl. Siehe `help conditions`" msgid "%.*s: invalid conversion specification" msgstr "%.*s: Ungültige Umwandlungsspezifikation" +#, 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 0013087c5..4a4ef7657 100644 --- a/po/en.po +++ b/po/en.po @@ -80,6 +80,10 @@ msgstr "" msgid "%.*s: invalid conversion specification" msgstr "%.*s: invalid conversion specification" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/fr.po b/po/fr.po index 115cf6f3d..a115ffd20 100644 --- a/po/fr.po +++ b/po/fr.po @@ -181,6 +181,10 @@ msgstr "" msgid "%.*s: invalid conversion specification" msgstr "%.*s : spécification de conversion invalide" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/pl.po b/po/pl.po index 98a01916c..58c27e430 100644 --- a/po/pl.po +++ b/po/pl.po @@ -76,6 +76,10 @@ msgstr "" msgid "%.*s: invalid conversion specification" 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 af7b91020..93e7f3f9e 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -81,6 +81,10 @@ msgstr "" msgid "%.*s: invalid conversion specification" msgstr "%.*s: especificação de conversão inválida" +#, c-format +msgid "%ls: function name required" +msgstr "" + #, c-format msgid "%s" msgstr "" diff --git a/po/sv.po b/po/sv.po index d2895e808..fb2bed6da 100644 --- a/po/sv.po +++ b/po/sv.po @@ -77,6 +77,10 @@ msgstr "" msgid "%.*s: invalid conversion specification" 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 6b6cff0c3..a5e6ecd78 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -103,6 +103,10 @@ msgstr "$status 不是有效的命令。参见 `help conditions`" msgid "%.*s: invalid conversion specification" msgstr "%.*s: 无效的转换规范" +#, 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 fa3089e59..88649cfb6 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!( "%s: %s: 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