aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index e5e7a53..aa6998d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -19,15 +19,19 @@ fn main() {
/*if rl.load_history("history.txt").is_err() {
println!("No previous history.");
}*/
- loop {
+ 'repl: loop {
let readline = rl.readline(&prompt.print(&cwd));
match readline {
Ok(line) => {
rl.add_history_entry(line.as_str());
let commands = parser::parse(&line);
match commands[0] {
- "cd" => {
- cwd = builtins::cd(commands[1]);
+ "cd" => match builtins::cd(&commands[1..], &prompt.home) {
+ Ok(p) => cwd = p,
+ Err(e) => eprintln!("Error: {}", e),
+ },
+ "exit" => {
+ break 'repl;
}
_ => {
builtins::run(commands[0], &commands[1..]);