diff --git a/src/lib/shell/mod.rs b/src/lib/shell/mod.rs index 3192ee9ebdca5f5b412b1ec805d4923b4df9a556..7a409d23f8367c4b9d4befc64c99dca102642b1b 100644 --- a/src/lib/shell/mod.rs +++ b/src/lib/shell/mod.rs @@ -496,6 +496,17 @@ impl<'a> Expander for Shell { hmap.get(&*key).unwrap_or(&VariableType::Str("".into())) )]) } + Select::Index(index) => { + use ranges::Index; + return Some(array![format!( + "{}", + hmap.get(&types::Str::from(match index { + Index::Forward(n) => n as isize, + Index::Backward(n) => -((n+1) as isize) + }.to_string())) + .unwrap_or(&VariableType::Str("".into())) + )]) + } _ => (), } } else if let Some(bmap) = self.variables.get::<types::BTreeMap>(name) { @@ -525,6 +536,17 @@ impl<'a> Expander for Shell { bmap.get(&*key).unwrap_or(&VariableType::Str("".into())) )]) } + Select::Index(index) => { + use ranges::Index; + return Some(array![format!( + "{}", + bmap.get(&types::Str::from(match index { + Index::Forward(n) => n as isize, + Index::Backward(n) => -((n+1) as isize) + }.to_string())) + .unwrap_or(&VariableType::Str("".into())) + )]) + } _ => (), } }