diff options
| author | Jonas Maier <> | 2026-03-09 13:37:20 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-09 13:37:20 +0100 |
| commit | 35dd10890d7c6d1023d6c8647c0984b69b811410 (patch) | |
| tree | 3b8cf6ad62834451b8bd8a08bf5d37df6f9b2cfe /src/main.rs | |
| parent | 5cf5f57ce8aa303936fec70a61acb436825f52c7 (diff) | |
| download | pish-35dd10890d7c6d1023d6c8647c0984b69b811410.tar.gz | |
basic setup for unix socket comms
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index f038336..5d2643f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(unix_socket_ancillary_data)] + use std::collections::HashMap; use std::ffi::OsStr; use std::fs; @@ -5,7 +7,7 @@ use std::io::{self, IsTerminal, Read, Write}; use std::os::unix::ffi::OsStrExt; use std::os::unix::io::AsRawFd; use std::path::Path; -use std::process::{Command, Stdio}; +use std::process::{Command, Stdio, exit}; use std::sync::{Arc, Mutex}; use std::thread::sleep; use std::time::Duration; @@ -13,6 +15,7 @@ use std::time::Duration; pub mod basedir; pub mod completion; pub mod cursor; +pub mod date; pub mod history; pub mod linebuf; pub mod panic; @@ -20,7 +23,7 @@ pub mod parse; pub mod raw; pub mod reload; pub mod run; -pub mod date; +pub mod unix; use linebuf::LineBuf; use raw::*; @@ -67,6 +70,7 @@ pub struct Session { builtins: HashMap<BString, &'static dyn run::Builtin>, vars: HashMap<BString, BString>, funs: HashMap<BString, Ast<PreExpansion>>, + socket_running: Option<unix::SocketRunning>, /// n before end of history.len() /// 0 == not checking history @@ -133,7 +137,9 @@ impl Session { let new = if self.history_visit == 0 { Vec::new() } else { - self.history[self.history.len() - self.history_visit].cmd.clone() + self.history[self.history.len() - self.history_visit] + .cmd + .clone() }; io::stdout().write_all(&new).unwrap(); io::stdout().flush().unwrap(); @@ -165,7 +171,9 @@ impl Session { } // skip it - while let Some(x) = self.line.get_left() && !x.is_ascii_whitespace() { + while let Some(x) = self.line.get_left() + && !x.is_ascii_whitespace() + { self.line.left(); i += 1; } @@ -256,6 +264,7 @@ fn event_loop() { builtins: run::builtin_map(), prev_path: vec![b'.'], history_visit: 0, + socket_running: None, vars: HashMap::new(), funs: HashMap::new(), }; @@ -263,6 +272,7 @@ fn event_loop() { print!("{}", se.prompt()); let session = Arc::new(Mutex::new(se)); + let _sock_dropper = unix::listen(session.clone()); loop { let mut buf = [0u8; 1]; @@ -479,6 +489,7 @@ fn event_loop() { } fn main() { + unix::maybe_run_defined_function(); if !io::stdin().is_terminal() { println!("need to run in a tty"); return; |
