Skip to content
Snippets Groups Projects
Commit 69f5adad authored by Skyler Berg's avatar Skyler Berg
Browse files

Delete original draft of shell

This draft of the shell was written a while ago and was not used in
redox. After this commit I intend to merge the shell from redox into
this repository.
parent 4c62268c
No related branches found
No related tags found
No related merge requests found
extern crate ion;
fn main() {
loop {
ion::repl()
}
}
use std::process::{Command,Output};
pub struct InstructionOut {
pub stdout: String,
pub stderr: String,
}
pub fn run(args: &[&str]) -> Option<InstructionOut> {
let output: Option<Output>;
match args.len() {
0 => output = Command::new("").output().ok(),
1 => output = Command::new(&args[0]).output().ok(),
_ => output = Command::new(&args[0]).args(&args[1..]).output().ok(),
}
if output.is_some() {
let output = output.unwrap();
Some(InstructionOut {
stdout: String::from_utf8(output.stdout).ok().expect("No stdout"),
stderr: String::from_utf8(output.stderr).ok().expect("No stderr"),
})
} else {
None
}
}
#![feature(convert)]
pub mod command;
use std::io;
use command::*;
pub fn repl() {
let mut input = String::new();
match io::stdin().read_line(&mut input) {
Ok(_) => {
let out_wrap = run(input.trim().split_whitespace().collect::<Vec<&str>>().as_slice());
if out_wrap.is_some() {
let out = out_wrap.unwrap();
if out.stdout.is_empty() {
println!("{}",out.stderr.trim());
} else {
println!("{}",out.stdout.trim());
}
} else {
println!("{} is not a valid command", input.trim());
}
}
Err(error) => println!("Line Read Error: {}", error)
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment