no good reason to commit this. the code makes hello world into hellworld and i think that's funny.

This commit is contained in:
Lilly Rosaline 2021-10-05 22:49:41 -05:00
parent 315d97b358
commit f16073b955

View file

@ -33,6 +33,8 @@ pub fn parse_args(input: &str, mode: u8) -> Vec<String> {
let mut double_quote_end: Vec<usize> = vec![]; // List of ending double quotation marks.
let mut is_double_quoted: bool = false; // boolean showing if the current contents are quoted.
let mut parameter_index: usize = 0;
let mut arguments: Vec<String> = vec![];
for (i, c) in input.iter().enumerate() {
let c = *c;
@ -50,6 +52,8 @@ pub fn parse_args(input: &str, mode: u8) -> Vec<String> {
single_quote_begin.push(i);
is_single_quoted = true;
}
} else {
arguments.insert(parameter_index, c.to_string());
}
},
'\"' => { // Double quoted stuff works kind of like graves do in JavaScript. See the bash manual§3.1.2.3.
@ -61,18 +65,26 @@ pub fn parse_args(input: &str, mode: u8) -> Vec<String> {
double_quote_begin.push(i);
is_double_quoted = true;
}
} else {
arguments.insert(parameter_index, c.to_string());
}
}
_ => {}
' ' => {
if !escaped || !is_single_quoted || !is_double_quoted {
parameter_index += 1;
} else {
}
}
_ => {
let __: &String = &String::new();
let mut arg = arguments.get(parameter_index).unwrap_or(__).to_owned();
arg.push(c);
arguments.insert(parameter_index, arg.clone());
}
}
}
if single_quote_begin.len() != single_quote_end.len() {
panic!("Hanging single quotation mark: {}", single_quote_begin.get(single_quote_begin.len()).unwrap_or(&0));
}
if double_quote_begin.len() != double_quote_end.len() {
panic!("Hanging double quotation mark: {}", double_quote_begin.get(double_quote_begin.len()).unwrap_or(&0));
}
vec![]
arguments
},
///
0x10 => {