From 25cc01845afa076a943cc83e329e9c0aede7dd7f Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 29 May 2026 10:22:38 +0200 Subject: [PATCH] string: Fix swapped arguments in error message Really this could do with a bespoke error, but this'll do for now. --- src/builtins/string/replace.rs | 2 +- tests/checks/string.fish | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builtins/string/replace.rs b/src/builtins/string/replace.rs index 603108afa..8e63f5391 100644 --- a/src/builtins/string/replace.rs +++ b/src/builtins/string/replace.rs @@ -68,7 +68,7 @@ fn take_args( }; *optind += 1; let Some(replacement) = args.get(*optind).copied() else { - err_fmt!(Error::UNEXP_ARG_COUNT, 1, 2) + err_fmt!(Error::UNEXP_ARG_COUNT, 2, 1) .subcmd(cmd, subcmd) .finish(streams); return Err(STATUS_INVALID_ARGS); diff --git a/tests/checks/string.fish b/tests/checks/string.fish index 3dbafcef6..c23da8e9c 100644 --- a/tests/checks/string.fish +++ b/tests/checks/string.fish @@ -1311,7 +1311,7 @@ string replace --max-matches 99999999999999999999 string replace # CHECKERR: string replace: missing argument string replace one -# CHECKERR: string replace: expected 1 arguments; got 2 +# CHECKERR: string replace: expected 2 arguments; got 1 string replace -r o '${bad_name}' foobar # CHECKERR: string replace: Regular expression substitute error: unknown substring