aboutsummaryrefslogtreecommitdiffstats
path: root/src/run/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/run/mod.rs')
-rw-r--r--src/run/mod.rs23
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());
}
}