diff options
| author | Jonas Maier <> | 2026-03-10 18:03:39 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-10 18:03:39 +0100 |
| commit | 1361e3088224860b143755e9fe1f1d7ce033e476 (patch) | |
| tree | 2aaa89f1e20001b2cedd4055f24a30fcdff127d5 /src/run/mod.rs | |
| parent | ff3ac68d159869d57e2cc190236d08c64e00b867 (diff) | |
| download | pish-1361e3088224860b143755e9fe1f1d7ce033e476.tar.gz | |
clippy
Diffstat (limited to 'src/run/mod.rs')
| -rw-r--r-- | src/run/mod.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/run/mod.rs b/src/run/mod.rs index 6234b96..5666574 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -25,7 +25,7 @@ impl ExecError { pub fn error_message(&self) -> String { match self { ExecError::UnknownVariable(items) => { - format!("unknown variable: {}", String::from_utf8_lossy(&items)) + format!("unknown variable: {}", String::from_utf8_lossy(items)) } ExecError::ExecError(exit_code) => format!("{exit_code}"), ExecError::SpawnIO(cmd, error) => match error.kind() { @@ -43,8 +43,8 @@ impl ExecError { io::ErrorKind::InvalidFilename => { format!("{cmd} is not a valid file name") } - io::ErrorKind::ArgumentListTooLong => format!("too many arguments"), - io::ErrorKind::Interrupted => format!("got interrupted"), + io::ErrorKind::ArgumentListTooLong => String::from("too many arguments"), + io::ErrorKind::Interrupted => String::from("got interrupted"), io::ErrorKind::Unsupported => format!("{cmd} is not supported"), e => format!("I am surprised you can get this error here: {e:?}"), }, @@ -335,18 +335,17 @@ impl parse::Expander for Executor { return Err(ExecError::UnknownVariable(var)); } - if var[0].is_ascii_digit() { - if let Some(x) = String::from_utf8(var.clone()) + if var[0].is_ascii_digit() + && let Some(x) = String::from_utf8(var.clone()) .ok() .and_then(|x| x.parse::<usize>().ok()) - { - if let Some(args) = &self.args { - if x < args.len() { - return Ok(args[x].clone()); - } - } else if let Some(arg) = std::env::args_os().skip(x).next() { - return Ok(arg.into_encoded_bytes()); + { + if let Some(args) = &self.args { + if x < args.len() { + return Ok(args[x].clone()); } + } else if let Some(arg) = std::env::args_os().nth(x) { + return Ok(arg.into_encoded_bytes()); } } |
