Commit b477c2b9 authored by storyfeet's avatar storyfeet
Browse files

now has error fixed

parent 627cef17
......@@ -82,10 +82,14 @@ impl Variables {
/// Create a new scope. If namespace is true, variables won't be droppable across the scope
/// boundary
pub fn new_scope(&mut self, namespace: bool) { self.0.new_scope(namespace) }
pub fn new_scope(&mut self, namespace: bool) {
self.0.new_scope(namespace)
}
/// Exit the current scope
pub fn pop_scope(&mut self) { self.0.pop_scope() }
pub fn pop_scope(&mut self) {
self.0.pop_scope()
}
pub(crate) fn pop_scopes<'b>(
&'b mut self,
......@@ -196,9 +200,10 @@ impl Variables {
.map_err(|cause| Error::InvalidHex(variable.into(), cause))?;
Ok((c as char).to_string().into())
}
Some(("env", variable)) => {
env::var(variable).map(Into::into).map_err(|_| Error::UnknownEnv(variable.into()))
}
Some(("env", variable)) => match env::var(variable) {
Ok(v) => Ok(v.into()),
Err(_) => Ok("".into()),
},
Some(("super", _)) | Some(("global", _)) | None => {
// Otherwise, it's just a simple variable name.
match self.get(name) {
......@@ -293,7 +298,9 @@ pub(crate) mod tests {
impl Expander for VariableExpander {
type Error = IonError;
fn string(&self, var: &str) -> Result<types::Str, IonError> { self.0.get_str(var) }
fn string(&self, var: &str) -> Result<types::Str, IonError> {
self.0.get_str(var)
}
fn array(
&self,
......@@ -311,7 +318,9 @@ pub(crate) mod tests {
Ok(cmd.into())
}
fn tilde(&self, input: &str) -> Result<types::Str, Self::Error> { Ok(input.into()) }
fn tilde(&self, input: &str) -> Result<types::Str, Self::Error> {
Ok(input.into())
}
fn map_keys(&self, _name: &str) -> Result<types::Args, Self::Error> {
Err(expansion::Error::VarNotFound)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment