diff --git a/fish-rust/src/builtins/command.rs b/fish-rust/src/builtins/command.rs index 89ffed8e6..3aaf314f7 100644 --- a/fish-rust/src/builtins/command.rs +++ b/fish-rust/src/builtins/command.rs @@ -5,8 +5,8 @@ use crate::builtins::shared::{ STATUS_CMD_OK, STATUS_CMD_UNKNOWN, STATUS_INVALID_ARGS, }; use crate::ffi::parser_t; -use crate::path::path_get_paths; -use crate::wchar::{wstr, WString, L}; +use crate::path::{path_get_path, path_get_paths}; +use crate::wchar::{wstr, L}; use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t}; use crate::wutil::sprintf; @@ -71,10 +71,14 @@ pub fn r#command( let mut res = false; let optind = w.woptind; for arg in argv.iter().take(argc).skip(optind) { - // TODO: This always gets all paths, and then skips a bunch. - // For the common case, we want to get just the one path. - // Port this over once path.cpp is. - let paths: Vec = path_get_paths(arg, &*parser.get_vars()); + let paths = if opts.all { + path_get_paths(arg, &*parser.get_vars()) + } else { + match path_get_path(arg, &*parser.get_vars()) { + Some(p) => vec![p], + None => vec![], + } + }; for path in paths.iter() { res = true; diff --git a/fish-rust/src/builtins/type.rs b/fish-rust/src/builtins/type.rs index 2e6553cee..7cc392d8b 100644 --- a/fish-rust/src/builtins/type.rs +++ b/fish-rust/src/builtins/type.rs @@ -14,7 +14,7 @@ use crate::ffi::{ function_get_definition_file, function_get_definition_lineno, function_get_props_autoload, function_is_copy, }; -use crate::path::path_get_paths; +use crate::path::{path_get_path, path_get_paths}; use crate::wchar::{wstr, WString, L}; use crate::wchar_ffi::WCharFromFFI; use crate::wchar_ffi::WCharToFFI; @@ -190,7 +190,14 @@ pub fn r#type( } } - let paths: Vec = path_get_paths(arg, &*parser.get_vars()); + let paths = if opts.all { + path_get_paths(arg, &*parser.get_vars()) + } else { + match path_get_path(arg, &*parser.get_vars()) { + Some(p) => vec![p], + None => vec![], + } + }; for path in paths.iter() { found += 1;