aboutsummaryrefslogtreecommitdiffstats
path: root/src/run
diff options
context:
space:
mode:
Diffstat (limited to 'src/run')
-rw-r--r--src/run/mod.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/run/mod.rs b/src/run/mod.rs
index c7414a8..e041066 100644
--- a/src/run/mod.rs
+++ b/src/run/mod.rs
@@ -305,7 +305,11 @@ impl Executor {
impl parse::Expander for Executor {
type Error = ExecError;
- fn expand_var(&mut self, var: BString) -> Result<BString, Self::Error> {
+ fn expand_var(
+ &mut self,
+ var: BString,
+ default: Option<BString>,
+ ) -> Result<BString, Self::Error> {
if var.is_empty() {
return Err(ExecError::UnknownVariable(var));
}
@@ -331,7 +335,10 @@ impl parse::Expander for Executor {
match std::env::var_os(OsStr::from_bytes(&var)) {
Some(val) => Ok(val.as_bytes().to_vec()),
- None => Err(ExecError::UnknownVariable(var)),
+ None => match default {
+ Some(d) => Ok(d),
+ None => Err(ExecError::UnknownVariable(var)),
+ },
}
}