1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use shells;
use crateSTDRESULT;
// const ALIASES: [(&str,&[&str]);4] = [
// ("(catalog)", &["(ls)","(dir)","(cat)"]),
// ("(delete)" , &["(del)","(era)"]),
// ("(tokenize)" , &["(tok)"]),
// ("(detokenize)" , &["(dtok)"])
// ];
// fn refine_zsh(script: &str) -> String {
// let aliases = std::collections::HashMap::from(ALIASES);
// let eq_patt = regex::RegexBuilder::new(r"^'--(\w+)=\[").multi_line(true).build().expect("regex parsing error");
// let alias_patt = regex::Regex::new(r"^\(\w+\)$").expect("regex parsing error");
// let intermediate = eq_patt.replace_all(script, "'--$1+[");
// let mut new_script = String::new();
// let mut accum = String::new();
// let mut curr_cmd = String::new();
// let mut alias_list : &[&str] = aliases.get("(catalog)").unwrap();
// for line in intermediate.lines() {
// match alias_patt.find(line) {
// Some(res) if aliases.contains_key(res.as_str()) => {
// accum = line.to_string();
// accum += "\n";
// alias_list = aliases.get(res.as_str()).unwrap();
// curr_cmd = res.as_str().to_string();
// },
// _ => {
// if accum.len() > 0 {
// accum += line;
// accum += "\n";
// if line==";;" {
// new_script += &accum;
// for alias in alias_list {
// new_script += &accum.replace(&curr_cmd,alias);
// }
// accum = "".to_string();
// }
// } else {
// new_script += line;
// new_script += "\n";
// }
// }
// }
// }
// return new_script;
// }