Merge pull request #5040 from d3lm/delm/feat/wasi/set-current-dir

Add ability to initialize cwd from PWD when targeting WASI
This commit is contained in:
Jeong, YunWon
2023-08-27 03:37:46 +09:00
committed by GitHub

View File

@@ -63,6 +63,14 @@ pub use settings::{opts_with_clap, RunMode};
pub fn run(init: impl FnOnce(&mut VirtualMachine) + 'static) -> ExitCode {
env_logger::init();
// NOTE: This is not a WASI convention. But it will be convenient since POSIX shell always defines it.
#[cfg(target_os = "wasi")]
{
if let Ok(pwd) = env::var("PWD") {
let _ = env::set_current_dir(pwd);
};
}
let (settings, run_mode) = opts_with_clap();
// Be quiet if "quiet" arg is set OR stdin is not connected to a terminal