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:
@@ -1,2 +1 @@
|
||||
cd /
|
||||
switchroot /usr /etc
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user