Adapted old code to fit new codebase

This commit is contained in:
2025-03-15 17:54:08 -04:00
parent d4f8f023af
commit 7f21e5baa7
5 changed files with 81 additions and 29 deletions

View File

@@ -1,11 +1,20 @@
use crate::{libsh::error::ShResult, parse::{execute::prepare_argv, NdRule, Node}, prelude::*, procio::{borrow_fd, IoStack}};
use crate::{jobs::{ChildProc, JobBldr}, libsh::error::ShResult, parse::{execute::prepare_argv, NdRule, Node}, prelude::*, procio::{borrow_fd, IoStack}};
pub fn echo(node: Node, io_stack: &mut IoStack) -> ShResult<()> {
pub fn echo(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -> ShResult<()> {
let NdRule::Command { assignments: _, argv } = node.class else {
unreachable!()
};
assert!(!argv.is_empty());
let child_pgid = if let Some(pgid) = job.pgid() {
pgid
} else {
job.set_pgid(Pid::this());
Pid::this()
};
let child = ChildProc::new(Pid::this(), Some("echo"), Some(child_pgid))?;
job.push_child(child);
for redir in node.redirs {
io_stack.push_to_frame(redir);
}