init: Remove export and unset commands
They manipulate global state and none of the init scripts use them anymore.
This commit is contained in:
@@ -93,7 +93,6 @@ fn run_command(cmd: Command, config: &mut InitConfig) {
|
||||
match cmd {
|
||||
Command::Nothing => {}
|
||||
Command::Echo(text) => println!("{text}"),
|
||||
Command::Export(var, value) => unsafe { env::set_var(var, value) },
|
||||
Command::SwitchRoot(prefix, etcdir) => {
|
||||
switch_root(&prefix, &etcdir, config);
|
||||
}
|
||||
@@ -102,11 +101,6 @@ fn run_command(cmd: Command, config: &mut InitConfig) {
|
||||
eprintln!("init: failed to switch stdio to '{}': {}", stdio, err);
|
||||
}
|
||||
}
|
||||
Command::Unset(envs) => {
|
||||
for env in envs {
|
||||
unsafe { env::remove_var(&env) };
|
||||
}
|
||||
}
|
||||
Command::Nowait(cmd) => {
|
||||
if config.skip_cmd.contains(&cmd.cmd) {
|
||||
eprintln!("init: skipping '{} {}'", cmd.cmd, cmd.args.join(" "));
|
||||
|
||||
@@ -46,8 +46,6 @@ pub enum Command {
|
||||
|
||||
// Modify env
|
||||
Stdio(String),
|
||||
Export(String, String),
|
||||
Unset(Vec<String>),
|
||||
|
||||
// Misc
|
||||
Echo(String),
|
||||
@@ -63,20 +61,6 @@ impl Command {
|
||||
|
||||
match cmd.as_str() {
|
||||
"echo" => Ok(Command::Echo(args.collect::<Vec<_>>().join(" "))),
|
||||
"export" => {
|
||||
let Some(var) = args.next() else {
|
||||
return Err("init: failed to export: no argument".to_owned());
|
||||
};
|
||||
let mut value = String::new();
|
||||
if let Some(arg) = args.next() {
|
||||
value.push_str(&arg);
|
||||
}
|
||||
for arg in args {
|
||||
value.push(' ');
|
||||
value.push_str(&arg);
|
||||
}
|
||||
Ok(Command::Export(var, value))
|
||||
}
|
||||
"switchroot" => {
|
||||
let Some(prefix) = args.next() else {
|
||||
return Err("init: failed to switchroot: no argument".to_owned());
|
||||
@@ -95,7 +79,6 @@ impl Command {
|
||||
};
|
||||
Ok(Command::Stdio(stdio))
|
||||
}
|
||||
"unset" => Ok(Command::Unset(args.collect())),
|
||||
"nowait" => Ok(Command::Nowait(Process::parse(args)?)),
|
||||
"notify" => Ok(Command::Notify(Process::parse(args)?)),
|
||||
"scheme" => {
|
||||
|
||||
Reference in New Issue
Block a user