Files
shed/src/builtin/pwd.rs
pagedmov 2ea44c55e9 implemented 'type' and 'wait' builtins
fixed some tcsetpgrp() misbehavior

fixed not being able to redirect stderr from builtins
2026-03-01 17:14:48 -05:00

27 lines
481 B
Rust

use crate::{
libsh::error::ShResult,
parse::{NdRule, Node},
prelude::*,
procio::borrow_fd,
state,
};
pub fn pwd(node: Node) -> ShResult<()> {
let NdRule::Command {
assignments: _,
argv: _,
} = node.class
else {
unreachable!()
};
let stdout = borrow_fd(STDOUT_FILENO);
let mut curr_dir = env::current_dir().unwrap().to_str().unwrap().to_string();
curr_dir.push('\n');
write(stdout, curr_dir.as_bytes())?;
state::set_status(0);
Ok(())
}