init: Remove cd command

The working directory doesn't matter for services and login sessions
already cd to the user home directory. This removes one source of global
state manipulation.
This commit is contained in:
bjorn3
2026-02-19 20:26:51 +01:00
parent 0227c0677c
commit 029f56eebe
3 changed files with 0 additions and 13 deletions
-1
View File
@@ -1,2 +1 @@
cd /
switchroot /usr /etc
-5
View File
@@ -85,11 +85,6 @@ fn run(file: &Path, config: &InitConfig) -> Result<()> {
fn run_command(cmd: Command, config: &InitConfig) {
match cmd {
Command::Nothing => {}
Command::Cd(dir) => {
if let Err(err) = env::set_current_dir(&dir) {
eprintln!("init: failed to cd to '{}': {}", dir.display(), err);
}
}
Command::Echo(text) => println!("{text}"),
Command::Export(var, value) => unsafe { env::set_var(var, value) },
Command::SwitchRoot(prefix, etcdir) => {
-7
View File
@@ -41,7 +41,6 @@ pub enum Command {
Regular(String, Vec<String>),
// Modify env
Cd(PathBuf),
Stdio(String),
Export(String, String),
Unset(Vec<String>),
@@ -59,12 +58,6 @@ impl Command {
};
match cmd.as_str() {
"cd" => {
let Some(dir) = args.next() else {
return Err("init: failed to cd: no argument".to_owned());
};
Ok(Command::Cd(PathBuf::from(dir)))
}
"echo" => Ok(Command::Echo(args.collect::<Vec<_>>().join(" "))),
"export" => {
let Some(var) = args.next() else {