looks like I'm cookin with gas now

parse-tree
Jordan Orelli 2 years ago
parent fdbc638628
commit e2455594f4

@ -154,6 +154,14 @@ fn eval(line: String) -> Result<()> {
println!("{}", pb.as_path().as_os_str().to_str().unwrap());
return Ok(());
}
"cd" => {
let cwd = std::env::current_dir()?;
if parts.len() > 1 {
let target = cwd.join(parts[1]);
std::env::set_current_dir(target)?;
return Ok(());
}
}
"printenv" => {
if parts.len() > 1 {
let name = parts[1];
@ -188,6 +196,10 @@ fn eval(line: String) -> Result<()> {
}
_ => {
let mut proc = std::process::Command::new(cmd);
if parts.len() > 1 {
let args = parts[1..].to_vec();
proc.args(args);
}
match proc.spawn() {
Ok(mut child) => {
if let Err(e) = child.wait() {
@ -233,7 +245,9 @@ fn main() -> Result<()> {
if event.code == key::ENTER {
newline(stdout)?;
eval(line.pop())?;
if let Err(e) = eval(line.pop()) {
println!("error: {}", e);
}
prompt.print()?;
continue;
}

Loading…
Cancel
Save