Run
()
| 203 | |
| 204 | // Run |
| 205 | pub fn run() -> crate::user::shell::XCode |
| 206 | { |
| 207 | println!(); |
| 208 | |
| 209 | let mut prompt = crate::sys::prompt::Prompt::new(); |
| 210 | let histfile = "~/.sh-hist"; |
| 211 | prompt.hist.load(histfile); |
| 212 | prompt.compl.set(&shcomp); |
| 213 | |
| 214 | let mut success = true; |
| 215 | while let Some(cmd) = prompt.input(&promptstr(success)) |
| 216 | { |
| 217 | match exec(&cmd) |
| 218 | { |
| 219 | XCode::CMD_SUCCESS => |
| 220 | { |
| 221 | success = true; |
| 222 | }, |
| 223 | |
| 224 | XCode::SHEX => |
| 225 | { |
| 226 | break; |
| 227 | }, |
| 228 | |
| 229 | _ => |
| 230 | |
| 231 | { |
| 232 | success = false; |
| 233 | }, |
| 234 | } |
| 235 | |
| 236 | prompt.hist.add(&cmd); |
| 237 | prompt.hist.save(histfile); |
| 238 | crate::sys::console::drain(); |
| 239 | println!(); |
| 240 | } |
| 241 | |
| 242 | // Clears screen, move cursor to top of display |
| 243 | print!("\x1b[2J\x1b[1;1H"); |
| 244 | XCode::CMD_SUCCESS |
| 245 | } |
| 246 | |
| 247 | |
| 248 | // Shell completion |