mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 18:03:51 +01:00
Glob paths can fail. Communicates the error if it happens. thanks (jonathandturner)
This commit is contained in:
parent
375f311331
commit
1bc1bb6111
@ -45,7 +45,15 @@ pub fn rm(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||
file => full_path.push(file),
|
||||
}
|
||||
|
||||
for entry in glob(&full_path.to_string_lossy()).expect("Failed to read glob pattern") {
|
||||
let entries = glob(&full_path.to_string_lossy());
|
||||
|
||||
if entries.is_err() {
|
||||
return Err(ShellError::string("Invalid pattern."));
|
||||
}
|
||||
|
||||
let entries = entries.unwrap();
|
||||
|
||||
for entry in entries {
|
||||
match entry {
|
||||
Ok(path) => {
|
||||
if path.is_dir() {
|
||||
|
@ -88,14 +88,14 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
||||
.with_files(vec![FileWithContent(
|
||||
"cargo_sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "nu"
|
||||
version = "0.1.1"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>"]
|
||||
description = "A shell for the GitHub era"
|
||||
license = "ISC"
|
||||
edition = "2018"
|
||||
"#,
|
||||
[package]
|
||||
name = "nu"
|
||||
version = "0.1.1"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>"]
|
||||
description = "A shell for the GitHub era"
|
||||
license = "ISC"
|
||||
edition = "2018"
|
||||
"#,
|
||||
)])
|
||||
.test_dir_name();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user