From 1bcfc64e13b2158af23990d00f036e0068a4721a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 17 Nov 2025 20:14:30 +0100 Subject: [PATCH] status list-files: support multiple arguments This fixes an issue in fish_config, see https://github.com/fish-shell/fish-shell/commit/ee94272eaf15cb561d5e34325c086bc3aff31522#commitcomment-170660405 --- doc_src/cmds/status.rst | 4 ++-- src/builtins/status.rs | 39 ++++++++++++++++------------------- tests/checks/fish_config.fish | 4 ++++ 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/doc_src/cmds/status.rst b/doc_src/cmds/status.rst index 64c9b8f65..6fae22a9b 100644 --- a/doc_src/cmds/status.rst +++ b/doc_src/cmds/status.rst @@ -30,7 +30,7 @@ Synopsis status test-feature FEATURE status build-info status get-file FILE - status list-files [PATH] + status list-files [PATH ...] status help-sections status terminal status test-terminal-feature FEATURE @@ -118,7 +118,7 @@ The following operations (subcommands) are available: as well as the man pages and themes. Which files are included depends on build settings. Returns 0 if the file was included, 1 otherwise. -**list-files** *FILE* +**list-files** *FILE...* NOTE: this subcommand is mainly intended for fish's internal use; let us know if you want to use it elsewhere. This lists the files embedded in the fish binary at compile time. Only files where the path starts with the optional *FILE* argument are shown. diff --git a/src/builtins/status.rs b/src/builtins/status.rs index ebf1153ae..f7d395a7e 100644 --- a/src/builtins/status.rs +++ b/src/builtins/status.rs @@ -517,18 +517,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B } ); } - c @ STATUS_LIST_FILES => { - if args.len() > 1 { - streams.err.append(wgettext_fmt!( - BUILTIN_ERR_ARG_COUNT2, - cmd, - c.to_wstr(), - 1, - args.len() - )); - return Err(STATUS_INVALID_ARGS); - } - + STATUS_LIST_FILES => { cfg_if!( if #[cfg(not(feature = "embed-data"))] { streams @@ -537,16 +526,24 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B return Err(STATUS_CMD_ERROR); } else { use crate::util::wcsfilecmp_glob; - let mut paths = vec![]; - let arg = crate::common::wcs2bytes(args.first().unwrap_or(&L!(""))); - let arg = std::str::from_utf8(&arg).unwrap(); - let embedded_files = crate::autoload::Asset::iter().chain(Docs::iter()); - #[cfg(using_cmake)] - let embedded_files = embedded_files.chain(CMakeBinaryDir::iter()); - for path in embedded_files { - if arg.is_empty() || path.starts_with(arg) { - paths.push(bytes2wcstring(path.as_bytes())); + let mut add = |arg| { + let arg = crate::common::wcs2bytes(arg); + let arg = std::str::from_utf8(&arg).unwrap(); + let embedded_files = crate::autoload::Asset::iter().chain(Docs::iter()); + #[cfg(using_cmake)] + let embedded_files = embedded_files.chain(CMakeBinaryDir::iter()); + for path in embedded_files { + if arg.is_empty() || path.starts_with(arg) { + paths.push(bytes2wcstring(path.as_bytes())); + } + } + }; + if args.is_empty() { + add(L!("")); + } else { + for arg in args { + add(arg); } } diff --git a/tests/checks/fish_config.fish b/tests/checks/fish_config.fish index 3c22a8ede..5f7189020 100644 --- a/tests/checks/fish_config.fish +++ b/tests/checks/fish_config.fish @@ -142,6 +142,10 @@ fish_config theme show "fish default" # CHECK: {{\x1b\[m}}{{\x1b\[m}}echo{{\x1b\[m}} {{\x1b\[91m}}'{{\x1b\[33m}}Errors are the portal to discovery # CHECK: {{\x1b\[m}}{{\x1b\[m}}Th{{\x1b\[m}}{{\x1b\[90m}}is an autosuggestion +fish_config theme show ayu\ Dark ayu\ Light | string match -r '^.*ayu.*' +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}ayu Dark{{\x1b\[m}} +# CHECK: {{\x1b\[m}}{{\x1b\[4m}}ayu Light{{\x1b\[m}} + mkdir $__fish_config_dir/themes touch $__fish_config_dir/themes/custom-from-userconf.theme fish_config theme show | grep -E 'fish default|Default Dark|custom-from-userconf'