mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
OnceLock
This commit is contained in:
@@ -256,9 +256,14 @@ fn operating_system_info_impl() -> Option<OperatingSystemInfo> {
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn has_wsl_env_markers() -> bool {
|
||||
std::env::var_os("WSL_INTEROP").is_some()
|
||||
|| std::env::var_os("WSLENV").is_some()
|
||||
|| std::env::var_os("WSL_DISTRO_NAME").is_some()
|
||||
// Cache detection result since env vars are stable across process lifetime
|
||||
// and this function may be called multiple times.
|
||||
static CACHE: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*CACHE.get_or_init(|| {
|
||||
std::env::var_os("WSL_INTEROP").is_some()
|
||||
|| std::env::var_os("WSLENV").is_some()
|
||||
|| std::env::var_os("WSL_DISTRO_NAME").is_some()
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -77,12 +77,11 @@ fn default_env_context_str(cwd: &str, shell: &Shell) -> String {
|
||||
let os_block = operating_system_context_block();
|
||||
format!(
|
||||
r#"<environment_context>
|
||||
<cwd>{}</cwd>
|
||||
<cwd>{cwd}</cwd>
|
||||
<approval_policy>on-request</approval_policy>
|
||||
<sandbox_mode>read-only</sandbox_mode>
|
||||
<network_access>restricted</network_access>
|
||||
{}{}</environment_context>"#,
|
||||
cwd, shell_line, os_block
|
||||
{shell_line}{os_block}</environment_context>"#
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user