From 149fec8f0299be4f4cf03f6232b8ca4c893e66b0 Mon Sep 17 00:00:00 2001 From: Aditya Giri <74224708+adityagiri3600@users.noreply.github.com> Date: Tue, 17 Feb 2026 20:32:08 +0530 Subject: [PATCH] string: accept --char alias for pad and shorten Closes #12460 --- src/builtins/string/pad.rs | 3 ++- src/builtins/string/shorten.rs | 3 ++- tests/checks/string.fish | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/builtins/string/pad.rs b/src/builtins/string/pad.rs index afbb32cfa..651c8c9e3 100644 --- a/src/builtins/string/pad.rs +++ b/src/builtins/string/pad.rs @@ -23,7 +23,8 @@ fn default() -> Self { impl StringSubCommand<'_> for Pad { const LONG_OPTIONS: &'static [WOption<'static>] = &[ - // FIXME docs say `--char`, there was no long_opt with `--char` in C++ + // Support both spellings: docs use --char, older fish accepted --chars. + wopt(L!("char"), RequiredArgument, 'c'), wopt(L!("chars"), RequiredArgument, 'c'), wopt(L!("right"), NoArgument, 'r'), wopt(L!("center"), NoArgument, 'C'), diff --git a/src/builtins/string/shorten.rs b/src/builtins/string/shorten.rs index f0bbdeadc..142fa7153 100644 --- a/src/builtins/string/shorten.rs +++ b/src/builtins/string/shorten.rs @@ -25,7 +25,8 @@ fn default() -> Self { impl<'args> StringSubCommand<'args> for Shorten<'args> { const LONG_OPTIONS: &'static [WOption<'static>] = &[ - // FIXME: documentation says it's --char + // Support both spellings: docs use --char, older fish accepted --chars. + wopt(L!("char"), RequiredArgument, 'c'), wopt(L!("chars"), RequiredArgument, 'c'), wopt(L!("max"), RequiredArgument, 'm'), wopt(L!("no-newline"), NoArgument, 'N'), diff --git a/tests/checks/string.fish b/tests/checks/string.fish index 9cee20f5d..a7a57f8cf 100644 --- a/tests/checks/string.fish +++ b/tests/checks/string.fish @@ -47,7 +47,7 @@ string pad foo string pad -C foo # CHECK: foo -string pad -r -w 7 --chars - foo +string pad -r -w 7 --char - foo # CHECK: foo---- string pad -r -w 7 --chars - --center foo # CHECK: --foo-- @@ -1003,7 +1003,7 @@ string shorten --max 4 -c /// foobar string shorten --max 4 -c /// foobarnana # CHECK: f/// -string shorten --max 2 --chars "" foo +string shorten --max 2 --char "" foo # CHECK: fo string shorten foo foobar