forked from extern/nushell
fix ls with empty string (#12086)
# Description Fixes: #12054 It's cause by nu always add `/*` if there is a parameter in ls, then `ls ""` becomes `ls "/*"`. This pr tries to fix it by only append `/` character if pattern is not empty. # User-Facing Changes NaN # Tests + Formatting Done # After Submitting NaN --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
@ -90,6 +90,13 @@ impl Command for Ls {
|
||||
let pattern_arg = opt_for_glob_pattern(engine_state, stack, call, 0)?;
|
||||
let pattern_arg = {
|
||||
if let Some(path) = pattern_arg {
|
||||
// it makes no sense to list an empty string.
|
||||
if path.item.as_ref().is_empty() {
|
||||
return Err(ShellError::FileNotFoundCustom {
|
||||
msg: "empty string('') directory or file does not exist".to_string(),
|
||||
span: path.span,
|
||||
});
|
||||
}
|
||||
match path.item {
|
||||
NuGlob::DoNotExpand(p) => Some(Spanned {
|
||||
item: NuGlob::DoNotExpand(nu_utils::strip_ansi_string_unlikely(p)),
|
||||
|
Reference in New Issue
Block a user