summaryrefslogtreecommitdiffstats
path: root/src/pipeline/builtins
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-05 07:30:34 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-05 07:30:34 -0500
commitf9c5cb86304748baf0da99126bf75c5a3cd3e773 (patch)
tree7583e15d3e6b82db02b3815516309fc4bb4ebfb3 /src/pipeline/builtins
parenta30174620d6b64f838989a634c265a353b2ab117 (diff)
downloadnbsh-f9c5cb86304748baf0da99126bf75c5a3cd3e773.tar.gz
nbsh-f9c5cb86304748baf0da99126bf75c5a3cd3e773.zip
and more simplification
Diffstat (limited to 'src/pipeline/builtins')
-rw-r--r--src/pipeline/builtins/command.rs5
-rw-r--r--src/pipeline/builtins/mod.rs22
2 files changed, 12 insertions, 15 deletions
diff --git a/src/pipeline/builtins/command.rs b/src/pipeline/builtins/command.rs
index b69463b..fd5e322 100644
--- a/src/pipeline/builtins/command.rs
+++ b/src/pipeline/builtins/command.rs
@@ -1,5 +1,4 @@
-use async_std::io::{ReadExt as _, WriteExt as _};
-use std::os::unix::io::{AsRawFd as _, FromRawFd as _, IntoRawFd as _};
+use crate::pipeline::prelude::*;
pub struct Command {
exe: crate::parse::Exe,
@@ -41,7 +40,7 @@ impl Command {
self.io.pre_exec(f);
}
- pub fn spawn(self, env: &crate::Env) -> anyhow::Result<Child> {
+ pub fn spawn(self, env: &Env) -> anyhow::Result<Child> {
let Self { f, exe, io } = self;
(f)(exe, env, io)
}
diff --git a/src/pipeline/builtins/mod.rs b/src/pipeline/builtins/mod.rs
index 36e308a..003892d 100644
--- a/src/pipeline/builtins/mod.rs
+++ b/src/pipeline/builtins/mod.rs
@@ -1,13 +1,11 @@
-use std::os::unix::ffi::OsStrExt as _;
-use std::os::unix::process::ExitStatusExt as _;
-use users::os::unix::UserExt as _;
+use crate::pipeline::prelude::*;
pub mod command;
pub use command::{Child, Command};
type Builtin = &'static (dyn for<'a> Fn(
crate::parse::Exe,
- &'a crate::Env,
+ &'a Env,
command::Io,
) -> anyhow::Result<command::Child<'a>>
+ Sync
@@ -31,12 +29,12 @@ static BUILTINS: once_cell::sync::Lazy<
#[allow(clippy::unnecessary_wraps)]
fn cd(
exe: crate::parse::Exe,
- env: &crate::Env,
+ env: &Env,
io: command::Io,
) -> anyhow::Result<command::Child> {
async fn async_cd(
exe: crate::parse::Exe,
- _env: &crate::Env,
+ _env: &Env,
io: command::Io,
) -> std::process::ExitStatus {
macro_rules! bail {
@@ -121,12 +119,12 @@ fn cd(
// this later, since the binary seems totally fine
fn echo(
exe: crate::parse::Exe,
- env: &crate::Env,
+ env: &Env,
io: command::Io,
) -> anyhow::Result<command::Child> {
async fn async_echo(
exe: crate::parse::Exe,
- _env: &crate::Env,
+ _env: &Env,
io: command::Io,
) -> std::process::ExitStatus {
macro_rules! write_stdout {
@@ -159,7 +157,7 @@ fn echo(
fn and(
mut exe: crate::parse::Exe,
- env: &crate::Env,
+ env: &Env,
io: command::Io,
) -> anyhow::Result<command::Child> {
exe.shift();
@@ -175,7 +173,7 @@ fn and(
fn or(
mut exe: crate::parse::Exe,
- env: &crate::Env,
+ env: &Env,
io: command::Io,
) -> anyhow::Result<command::Child> {
exe.shift();
@@ -191,7 +189,7 @@ fn or(
fn command(
mut exe: crate::parse::Exe,
- env: &crate::Env,
+ env: &Env,
io: command::Io,
) -> anyhow::Result<command::Child> {
exe.shift();
@@ -202,7 +200,7 @@ fn command(
fn builtin(
mut exe: crate::parse::Exe,
- env: &crate::Env,
+ env: &Env,
io: command::Io,
) -> anyhow::Result<command::Child> {
exe.shift();