mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
expand tilde in externals
This commit is contained in:
parent
3424334ce5
commit
9f42d7693f
1 changed files with 17 additions and 1 deletions
|
@ -98,6 +98,8 @@ impl Command {
|
||||||
arg_string.push_str(&arg);
|
arg_string.push_str(&arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let home_dir = dirs::home_dir();
|
||||||
|
|
||||||
trace!(target: "nu::run::external", "command = {:?}", self.name);
|
trace!(target: "nu::run::external", "command = {:?}", self.name);
|
||||||
|
|
||||||
let mut process;
|
let mut process;
|
||||||
|
@ -129,6 +131,13 @@ impl Command {
|
||||||
if arg.chars().all(|c| c.is_whitespace()) {
|
if arg.chars().all(|c| c.is_whitespace()) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
// Let's also replace ~ as we shell out
|
||||||
|
let arg = if let Some(ref home_dir) = home_dir {
|
||||||
|
arg.replace("~", home_dir.to_str().unwrap())
|
||||||
|
} else {
|
||||||
|
arg.replace("~", "~")
|
||||||
|
};
|
||||||
|
|
||||||
Some(arg.replace("$it", &i))
|
Some(arg.replace("$it", &i))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -140,6 +149,13 @@ impl Command {
|
||||||
} else {
|
} else {
|
||||||
process = Exec::cmd(&self.name);
|
process = Exec::cmd(&self.name);
|
||||||
for arg in &self.args.list {
|
for arg in &self.args.list {
|
||||||
|
// Let's also replace ~ as we shell out
|
||||||
|
let arg = if let Some(ref home_dir) = home_dir {
|
||||||
|
arg.replace("~", home_dir.to_str().unwrap())
|
||||||
|
} else {
|
||||||
|
arg.replace("~", "~")
|
||||||
|
};
|
||||||
|
|
||||||
let arg_chars: Vec<_> = arg.chars().collect();
|
let arg_chars: Vec<_> = arg.chars().collect();
|
||||||
if arg_chars.len() > 1
|
if arg_chars.len() > 1
|
||||||
&& arg_chars[0] == '"'
|
&& arg_chars[0] == '"'
|
||||||
|
@ -149,7 +165,7 @@ impl Command {
|
||||||
let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect();
|
let new_arg: String = arg_chars[1..arg_chars.len() - 1].iter().collect();
|
||||||
process = process.arg(new_arg);
|
process = process.arg(new_arg);
|
||||||
} else {
|
} else {
|
||||||
process = process.arg(arg.arg.clone());
|
process = process.arg(arg.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue