aboutsummaryrefslogtreecommitdiff
path: root/src/builtins.rs
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-10-17 17:55:44 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-10-17 19:22:59 +0300
commit3cce88f681029385ac3e80a9990346f9272f15e1 (patch)
tree885e3b994134857f54831761bd1c6cbda25d5772 /src/builtins.rs
parentAdd ! builtin to display the last status (diff)
downloadrshell-3cce88f681029385ac3e80a9990346f9272f15e1.tar.xz
Add new tokenizer
Diffstat (limited to 'src/builtins.rs')
-rw-r--r--src/builtins.rs73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/builtins.rs b/src/builtins.rs
deleted file mode 100644
index bcc14f1..0000000
--- a/src/builtins.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-use std::io::{Error, ErrorKind};
-use std::path::{Path, PathBuf};
-use std::process::Command;
-
-pub fn cd(args: &[&str], home: &PathBuf) -> Result<PathBuf, Error> {
- if args.len() > 1 {
- return Err(Error::new(
- ErrorKind::InvalidInput,
- "Too many arguments passed to cd",
- ));
- }
-
- if args.len() == 0 {
- return Ok(home.to_path_buf());
- }
-
- let root = match std::fs::canonicalize(Path::new(args[0])) {
- Ok(p) => p,
- Err(_) => Path::new("/").to_path_buf(),
- };
-
- match std::env::set_current_dir(&root) {
- Ok(_) => Ok(root.to_path_buf()),
- Err(e) => Err(e),
- }
-}
-
-pub fn run(command: &str, args: &[&str]) -> Result<std::process::ExitStatus, Error> {
- let mut child = Command::new(command).args(args).spawn()?;
- child.wait()
-}
-/*
- match command {
-
- command => {
- let stdin = match previous_command {
- None => Stdio::inherit(),
- Some(cmd) => Stdio::from(cmd.stdout.unwrap()),
- };
- let stdout = match commands.peek().is_some() {
- true => Stdio::piped(),
- false => Stdio::inherit(),
- };
-
- let child = Command::new(command)
- .args(args)
- .stdin(stdin)
- .stdout(stdout)
- .spawn();
- match child {
- Ok(c) => previous_command = Some(c),
- Err(e) => {
- previous_command = None;
- eprintln!("{}", e);
- }
- }
- }
- }
-}
-
-if let Some(mut final_command) = previous_command {
- match final_command.wait() {
- Ok(ret) => match ret.code() {
- Some(code) => {
- if cfg!(debug_assertions) {
- println!("exit code [{}]", code);
- }
- }
- None => println!("Process termed by signal"),
- },
- Err(e) => eprintln!("error waiting on final command: {}", e),
- }
-}*/