Don't error on failed external expansion (#4480)

This commit is contained in:
JT 2022-02-15 08:47:25 -05:00 committed by GitHub
parent 9114a2d31d
commit 5c1a1be02b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -358,14 +358,10 @@ impl ExternalCommand {
if let Ok((prefix, matches)) = nu_engine::glob_from(&arg, &cwd, self.name.span) {
let matches: Vec<_> = matches.collect();
// Following shells like bash, if we can't expand a glob pattern, we don't assume an empty arg
// Instead, we throw an error. This helps prevent issues with things like `ls unknowndir/*` accidentally
// listening the current directory.
// FIXME: do we want to special-case this further? We might accidentally expand when they don't
// intend to
if matches.is_empty() {
return Err(ShellError::FileNotFoundCustom(
"pattern not found".to_string(),
arg.span,
));
process.arg(&arg.item);
}
for m in matches {
if let Ok(arg) = m {