From 029f56eebedd705205e3eed6d4a4e314625c9c09 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:26:51 +0100 Subject: [PATCH] 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. --- init.d/90_exit_initfs | 1 - init/src/main.rs | 5 ----- init/src/script.rs | 7 ------- 3 files changed, 13 deletions(-) diff --git a/init.d/90_exit_initfs b/init.d/90_exit_initfs index 64291d12dd..dea1136bd9 100644 --- a/init.d/90_exit_initfs +++ b/init.d/90_exit_initfs @@ -1,2 +1 @@ -cd / switchroot /usr /etc diff --git a/init/src/main.rs b/init/src/main.rs index 7699b6015b..6035b226f3 100644 --- a/init/src/main.rs +++ b/init/src/main.rs @@ -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) => { diff --git a/init/src/script.rs b/init/src/script.rs index 8c1b30772c..c118ce888d 100644 --- a/init/src/script.rs +++ b/init/src/script.rs @@ -41,7 +41,6 @@ pub enum Command { Regular(String, Vec), // Modify env - Cd(PathBuf), Stdio(String), Export(String, String), Unset(Vec), @@ -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::>().join(" "))), "export" => { let Some(var) = args.next() else {