Skip to content
Snippets Groups Projects
Commit b477c2b9 authored by storyfeet's avatar storyfeet
Browse files

now has error fixed

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