fix(core): keep the IDE's temporary files in a folder only this user can open (#8378)

Several features wrote into fixed or guessable names directly under the system
temporary folder, which every user shares on Linux: the terminal's shell
integration scripts, Gradle init scripts, Java argument files, binaries and
classes of single-file runs, jdtls' temporary folder, the TypeScript watch
scratch folder, Claude and Copilot session files, the Android emulator and
Xcode build logs, CPU profiles, `devicectl` output and the throwaway Docker
config. Another local user could create those folders first and have the IDE
user run their code, or read and overwrite the files.

They now all live under `<temp>/openidea-<uid>` (`ide_core::private_temp`),
created owner-only; a name that belongs to someone else or is a symbolic link
is never used, and a folder of a random name takes its place for that run.

Co-authored-by: rohitdanda <[email protected]>
Цей коміт міститься в:
l0ng-aiтаrohitdanda authored and GitHub committed 2026-12-06 20:29:20 +08:00
1 джерело 6b5008f02e
коміт c4b2d24d7e
22 files changed
+156 -89

No files matched your search

+4 -4
Переглянути файл
@@ -3,9 +3,9 @@
//!
//! Each ACP session runs its own `claude` process, whose session id is the ACP one.
//! The CLI writes a session's transcript only once it has a message, so a fork or an
//! undo that has not been prompted yet is kept as a pending start (`<temp>/openidea-claude/
//! <id>.json`): loading that session, from this connection or a fresh one, starts it that
//! way.
//! undo that has not been prompted yet is kept as a pending start (`claude/<id>.json` in this
//! user's temporary folder, `ide_core::private_temp`): loading that session, from this
//! connection or a fresh one, starts it that way.
pub(crate) mod cli;
pub(crate) mod history;
@@ -62,7 +62,7 @@ pub(crate) fn connect(
args: spec.args.clone(),
env: spec.env.clone(),
config_dir: cli::config_dir(&spec.env),
pending_dir: std::env::temp_dir().join("openidea-claude"),
pending_dir: ide_core::private_temp::dir("claude")?,
cwd: cwd.to_path_buf(),
};
let shim = Shim::new(config, Arc::new(cli::Process), Arc::from(on_stderr));
+1 -2
Переглянути файл
@@ -1404,8 +1404,7 @@ fn write_temp_image(session_id: &str, mime: &str, base64_data: &str) -> Option<P
if bytes.is_empty() {
return None;
}
let dir = std::env::temp_dir().join("openidea-copilot");
std::fs::create_dir_all(&dir).ok()?;
let dir = ide_core::private_temp::dir("copilot").ok()?;
let safe_sid: String = session_id.chars().filter(|c| c.is_ascii_alphanumeric() || *c == '-').collect();
let file = dir.join(format!("{safe_sid}-{}.{ext}", uuid::Uuid::new_v4().simple()));
std::fs::write(&file, &bytes).ok()?;
+1 -1
Переглянути файл
@@ -116,7 +116,7 @@ pub fn launch_emulator(avd: &str) -> IdeResult<()> {
fn start_emulator(emulator: &Path, avd: &str) -> IdeResult<()> {
let name: String = avd.chars().map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }).collect();
let log_path = std::env::temp_dir().join(format!("openidea-emulator-{name}.log"));
let log_path = ide_core::private_temp::dir("android")?.join(format!("emulator-{name}.log"));
let log = std::fs::File::create(&log_path)?;
let mut cmd = Command::new(emulator);
cmd.arg("-avd").arg(avd);
+2 -5
Переглянути файл
@@ -213,11 +213,8 @@ impl Scratch {
use std::hash::{Hash, Hasher};
let mut hash = std::collections::hash_map::DefaultHasher::new();
config.hash(&mut hash);
let dir = std::env::temp_dir().join("openidea-tsc-watch").join(format!(
"{}-{:016x}",
std::process::id(),
hash.finish()
));
let dir =
ide_core::private_temp::dir("tsc-watch")?.join(format!("{}-{:016x}", std::process::id(), hash.finish()));
// Fresh: a `.tsbuildinfo` left by an earlier run would make tsc skip unchanged projects.
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir)?;
+1
Переглянути файл
@@ -24,6 +24,7 @@ pub mod network_path;
pub mod output_encoding;
pub mod output_rate;
pub mod platform;
pub mod private_temp;
pub mod process;
pub mod project_dir;
pub mod project_env;
+97
Переглянути файл
@@ -0,0 +1,97 @@
//! Folders of this user in the system temporary folder.
//!
//! `/tmp` is shared by every user on Linux, so a fixed name there (`/tmp/openidea-gradle`) can be
//! created first by another user, who then controls the scripts, argument files and binaries
//! written into it. Everything goes under `<temp>/openidea-<uid>`, created owner-only; when that
//! name belongs to someone else or is a symbolic link, under a folder of a random name instead.
use std::io;
use std::path::PathBuf;
/// `<temp>/openidea-<uid>/<name>`, created when missing. `name` is a plain folder name.
pub fn dir(name: &str) -> io::Result<PathBuf> {
debug_assert!(!name.is_empty() && !name.contains(['/', '\\']), "{name}");
let dir = root()?.join(name);
std::fs::create_dir_all(&dir)?;
Ok(dir)
}
#[cfg(unix)]
fn root() -> io::Result<PathBuf> {
use std::os::unix::fs::{DirBuilderExt, MetadataExt, PermissionsExt};
static TAKEN: std::sync::OnceLock<PathBuf> = std::sync::OnceLock::new();
if let Some(own) = TAKEN.get() {
return Ok(own.clone());
}
// SAFETY: `geteuid` has no preconditions and cannot fail.
let uid = unsafe { libc::geteuid() };
let root = std::env::temp_dir().join(format!("openidea-{uid}"));
match std::fs::DirBuilder::new().mode(0o700).create(&root) {
Ok(()) => {}
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => {}
Err(e) => return Err(e),
}
let meta = std::fs::symlink_metadata(&root)?;
if !meta.is_dir() || meta.uid() != uid {
// Someone else took the name: a fresh folder of a random name for the rest of this run,
// rather than no temporary files at all.
let own = unique(&root)?;
return Ok(TAKEN.get_or_init(|| own).clone());
}
if meta.mode() & 0o077 != 0 {
std::fs::set_permissions(&root, std::fs::Permissions::from_mode(0o700))?;
}
Ok(root)
}
/// `<root>-XXXXXX`, created owner-only by `mkdtemp`.
#[cfg(unix)]
fn unique(root: &std::path::Path) -> io::Result<PathBuf> {
use std::os::unix::ffi::{OsStrExt, OsStringExt};
let mut template = root.as_os_str().as_bytes().to_vec();
template.extend_from_slice(b"-XXXXXX\0");
// SAFETY: `template` is a writable, NUL-terminated buffer that outlives the call.
if unsafe { libc::mkdtemp(template.as_mut_ptr().cast()) }.is_null() {
return Err(io::Error::last_os_error());
}
template.pop();
Ok(PathBuf::from(std::ffi::OsString::from_vec(template)))
}
/// The temporary folder is the user's own (`%LOCALAPPDATA%\Temp`).
#[cfg(not(unix))]
fn root() -> io::Result<PathBuf> {
Ok(std::env::temp_dir().join("openidea"))
}
#[cfg(all(test, unix))]
mod tests {
use super::*;
use std::os::unix::fs::{MetadataExt, PermissionsExt};
#[test]
fn folders_are_under_an_owner_only_root() {
let made = dir("private-temp-test").unwrap();
let root = made.parent().unwrap();
let meta = std::fs::symlink_metadata(root).unwrap();
assert_eq!(meta.mode() & 0o777, 0o700);
assert_eq!(meta.uid(), unsafe { libc::geteuid() });
assert!(root.starts_with(std::env::temp_dir()));
assert!(made.is_dir());
// A root left group- or world-accessible is narrowed again.
std::fs::set_permissions(root, std::fs::Permissions::from_mode(0o755)).unwrap();
dir("private-temp-test").unwrap();
assert_eq!(std::fs::symlink_metadata(root).unwrap().mode() & 0o777, 0o700);
let _ = std::fs::remove_dir(&made);
}
#[test]
fn a_taken_name_falls_back_to_a_fresh_owner_only_folder() {
let tmp = tempfile::tempdir().unwrap();
let a = unique(&tmp.path().join("openidea-1")).unwrap();
let b = unique(&tmp.path().join("openidea-1")).unwrap();
assert_ne!(a, b);
assert!(a.file_name().unwrap().to_string_lossy().starts_with("openidea-1-"));
assert_eq!(std::fs::symlink_metadata(&a).unwrap().mode() & 0o777, 0o700);
}
}
+2 -2
Переглянути файл
@@ -78,8 +78,8 @@ impl DebugManager {
};
self.js_page_request(s, "stopProfile", json!({})).await?;
static HANDED_OVER: AtomicU32 = AtomicU32::new(0);
let dir = std::env::temp_dir().join(format!(
"openidea-js-profile-{}-{}-{}",
let dir = ide_core::private_temp::dir("js-profile")?.join(format!(
"{}-{}-{}",
std::process::id(),
s.0,
HANDED_OVER.fetch_add(1, Ordering::Relaxed)
+2 -2
Переглянути файл
@@ -1373,7 +1373,7 @@ fn json_args_len(args: &Value, key: &str) -> usize {
pub(crate) fn shorten_java_analyzer_classpath(s: &Arc<Session>, args: &mut Value) -> ide_core::IdeResult<()> {
let cwd = args.get("cwd").and_then(Value::as_str).map(PathBuf::from).unwrap_or_else(|| s.spec.cwd.clone());
if let Some(jar) =
shorten_java_analyzer_classpath_with(args, &cwd, cfg!(windows), &ide_run::java_cmdline::default_temp_dir())?
shorten_java_analyzer_classpath_with(args, &cwd, cfg!(windows), &ide_run::java_cmdline::default_temp_dir()?)?
{
s.temp_files.lock().push(TempFile(jar));
}
@@ -1444,7 +1444,7 @@ pub(crate) async fn start_kotlin_debuggee(s: &Arc<Session>, args: &mut Value) ->
&java_args,
&s.spec.cwd,
cfg!(windows),
&ide_run::java_cmdline::default_temp_dir(),
&ide_run::java_cmdline::default_temp_dir()?,
)? {
java_args = shortened.args;
s.temp_files.lock().push(TempFile(shortened.file));
+1 -6
Переглянути файл
@@ -304,13 +304,8 @@ impl TempConfig {
pub fn new() -> IdeResult<Self> {
let nanos =
std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_nanos()).unwrap_or(0);
let dir = std::env::temp_dir().join(format!("openidea-docker-{}-{nanos}", std::process::id()));
let dir = ide_core::private_temp::dir("docker")?.join(format!("{}-{nanos}", std::process::id()));
std::fs::create_dir_all(&dir)?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let _ = std::fs::set_permissions(&dir, std::fs::Permissions::from_mode(0o700));
}
if let Some(contexts) = user_config_dir().map(|d| d.join("contexts")).filter(|d| d.is_dir()) {
let _ = copy_dir(&contexts, &dir.join("contexts"));
}
+1 -25
Переглянути файл
@@ -117,31 +117,7 @@ fn remove_old_logs(dir: &Path, max_age: std::time::Duration) {
/// A directory only this user can read: output may hold secrets, and `/tmp` is shared on Linux.
fn output_dir() -> IdeResult<PathBuf> {
#[cfg(unix)]
{
use std::os::unix::fs::{DirBuilderExt, MetadataExt};
let uid = rustix::process::getuid().as_raw();
let dir = std::env::temp_dir().join(format!("openidea-mcp-{uid}"));
match std::fs::DirBuilder::new().mode(0o700).create(&dir) {
Ok(()) => {}
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {}
Err(e) => return Err(e.into()),
}
let meta = std::fs::symlink_metadata(&dir)?;
if !meta.is_dir() || meta.uid() != uid || meta.mode() & 0o077 != 0 {
return Err(ide_core::IdeError::new(
ide_core::error::ErrorKind::PermissionDenied,
format!("{} is not a private directory of this user", dir.display()),
));
}
Ok(dir)
}
#[cfg(not(unix))]
{
let dir = std::env::temp_dir().join("openidea-mcp");
std::fs::create_dir_all(&dir)?;
Ok(dir)
}
Ok(ide_core::private_temp::dir("mcp")?)
}
#[cfg(test)]
+4 -4
Переглянути файл
@@ -736,10 +736,10 @@ fn split_build_log(
let name: String =
config.id.chars().map(|c| if c.is_ascii_alphanumeric() || "._-".contains(c) { c } else { '_' }).collect();
let project_key = project.cache_dir.file_name().unwrap_or_default();
let path = std::env::temp_dir().join("openidea-xcode-build").join(project_key).join(format!("{name}.log"));
let file = std::fs::create_dir_all(path.parent().unwrap_or(&path))
.and_then(|()| std::fs::File::create(&path))
.map(std::io::BufWriter::new);
let dir = ide_core::private_temp::dir("xcode-build").map(|d| d.join(project_key));
let path = dir.as_ref().map(|d| d.join(format!("{name}.log"))).unwrap_or_default();
let file =
dir.and_then(std::fs::create_dir_all).and_then(|()| std::fs::File::create(&path)).map(std::io::BufWriter::new);
let file = match file {
Ok(file) => Some(file),
Err(e) => {
+4 -2
Переглянути файл
@@ -173,7 +173,8 @@ pub async fn run_env_files(files: Vec<std::path::PathBuf>) -> IdeResult<std::col
pub async fn run_gradle_jvm_args_script(jvm_args: Vec<String>) -> IdeResult<String> {
// The forked JVMs: `bootRun`, `run`, tests; the path is for `--init-script`.
tokio::task::spawn_blocking(move || {
ide_run::gradle_jvm::write_init_script(&ide_run::gradle_jvm::default_dir(), &jvm_args)
ide_run::gradle_jvm::default_dir()
.and_then(|dir| ide_run::gradle_jvm::write_init_script(&dir, &jvm_args))
.map(|p| p.to_string_lossy().into_owned())
.map_err(|e| IdeError::internal(format!("cannot write the Gradle init script: {e}")))
})
@@ -189,7 +190,8 @@ pub async fn run_gradle_init_script(name: String, text: String) -> IdeResult<Str
return Err(IdeError::invalid(format!("invalid init script name {name:?}")));
}
tokio::task::spawn_blocking(move || {
ide_run::gradle_jvm::write_script(&ide_run::gradle_jvm::default_dir(), &name, &text)
ide_run::gradle_jvm::default_dir()
.and_then(|dir| ide_run::gradle_jvm::write_script(&dir, &name, &text))
.map(|p| p.to_string_lossy().into_owned())
.map_err(|e| IdeError::internal(format!("cannot write the Gradle init script: {e}")))
})
+3 -3
Переглянути файл
@@ -191,7 +191,7 @@ fn package_name(file: &Path) -> Option<String> {
}
/// A stable directory per source file, so a rebuild reuses classes of unchanged files.
fn compile_dir(file: &Path) -> PathBuf {
fn compile_dir(file: &Path) -> std::io::Result<PathBuf> {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
file.hash(&mut hasher);
let stem: String = file
@@ -201,7 +201,7 @@ fn compile_dir(file: &Path) -> PathBuf {
.chars()
.map(|c| if c.is_ascii_alphanumeric() || c == '-' || c == '_' { c } else { '-' })
.collect();
std::env::temp_dir().join("openidea-run").join(format!("java-{stem}-{:x}", hasher.finish()))
Ok(ide_core::private_temp::dir("run")?.join(format!("java-{stem}-{:x}", hasher.finish())))
}
/// Replaces `config` with `java -cp <project> <class>` after compiling the file with the
@@ -274,7 +274,7 @@ pub(super) async fn prepare(
}
let sources = module.as_ref().map(|m| m.sources.as_slice()).unwrap_or_default();
let libraries = module.as_ref().map(|m| m.libraries.as_slice()).unwrap_or_default();
let out = compile_dir(&file);
let out = compile_dir(&file).map_err(|e| IdeError::internal(format!("Cannot create the output folder ({e})")))?;
std::fs::create_dir_all(&out).map_err(|e| IdeError::internal(format!("Cannot create {} ({e})", out.display())))?;
let mut args: Vec<String> = vec!["-g".into(), "-d".into(), out.to_string_lossy().into_owned()];
if !libraries.is_empty() {
+6 -4
Переглянути файл
@@ -408,10 +408,12 @@ pub async fn sdk_locate_tools(
near: Option<PathBuf>,
) -> IdeResult<LocatedTools> {
host.require_trust_if_project(window)?;
blocking_value(move || LocatedTools {
tools: ide_sdk::locate::locate_tools(&names, near.as_deref()),
compile_dir: ide_sdk::locate::compile_dir().into(),
macos_sysroot: ide_sdk::locate::macos_sysroot().map(Into::into),
blocking(move || {
Ok(LocatedTools {
tools: ide_sdk::locate::locate_tools(&names, near.as_deref()),
compile_dir: ide_sdk::locate::compile_dir()?.into(),
macos_sysroot: ide_sdk::locate::macos_sysroot().map(Into::into),
})
})
.await
}
+3 -3
Переглянути файл
@@ -54,9 +54,9 @@ pub fn init_script(jvm_args: &[String]) -> String {
)
}
/// Where the scripts are written.
pub fn default_dir() -> PathBuf {
std::env::temp_dir().join("openidea-gradle")
/// Where the scripts are written: a folder of this user, as Gradle runs what it finds there.
pub fn default_dir() -> std::io::Result<PathBuf> {
ide_core::private_temp::dir("gradle")
}
/// Writes the script for `jvm_args` under `dir` (named by its content, so launches share
+2 -2
Переглянути файл
@@ -238,8 +238,8 @@ pub fn shorten_classpath_to_jar(
}
/// Where launches put their pathing jars / argfiles.
pub fn default_temp_dir() -> PathBuf {
std::env::temp_dir().join("openidea-classpath")
pub fn default_temp_dir() -> std::io::Result<PathBuf> {
ide_core::private_temp::dir("classpath")
}
fn temp_file(dir: &Path, ext: &str) -> PathBuf {
+5 -6
Переглянути файл
@@ -271,7 +271,8 @@ fn shorten_java(inv: &mut Invocation, config: &RunConfig, cwd: &Path) -> IdeResu
} else {
inv.program.clone()
};
let dir = crate::java_cmdline::default_temp_dir();
let dir = crate::java_cmdline::default_temp_dir()
.map_err(|e| IdeError::internal(format!("cannot shorten the command line: {e}")))?;
let shortened = crate::java_cmdline::shorten(&java, &inv.args, cwd, cfg!(windows), &dir)
.map_err(|e| IdeError::internal(format!("cannot shorten the command line: {e}")))?;
let Some(s) = shortened else { return Ok(TempFile(None)) };
@@ -307,11 +308,9 @@ fn match_console_encoding(
env.vars.extend(fix.env);
let mut prepend = fix.java_args;
if fix.gradle_init_script {
match crate::gradle_jvm::write_script(
&crate::gradle_jvm::default_dir(),
"file-encoding",
output_encoding::GRADLE_FILE_ENCODING_SCRIPT,
) {
match crate::gradle_jvm::default_dir().and_then(|dir| {
crate::gradle_jvm::write_script(&dir, "file-encoding", output_encoding::GRADLE_FILE_ENCODING_SCRIPT)
}) {
Ok(script) => prepend.extend(["--init-script".to_owned(), script.to_string_lossy().into_owned()]),
Err(e) => tracing::warn!("cannot write the Gradle file.encoding init script: {e}"),
}
+2 -1
Переглянути файл
@@ -128,7 +128,8 @@ pub fn parse_devices(json: &str) -> IdeResult<Vec<IosSimulator>> {
/// `devicectl` (Xcode 15 and later) is missing or fails. `dir` picks the project's Xcode.
pub fn devices(dir: &Path) -> Vec<IosSimulator> {
let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap_or_default().as_nanos();
let file = std::env::temp_dir().join(format!("openidea-devicectl-{}-{stamp}.json", std::process::id()));
let Ok(out) = ide_core::private_temp::dir("devicectl") else { return Vec::new() };
let file = out.join(format!("{}-{stamp}.json", std::process::id()));
let path = file.to_string_lossy().into_owned();
let listed = run_in(Some(dir), "xcrun", &["devicectl", "list", "devices", "--quiet", "--json-output", &path]);
let json = std::fs::read_to_string(&file);
+1 -1
Переглянути файл
@@ -624,7 +624,7 @@ fn long_java_classpath_is_shortened() {
let file = first
.split(' ')
.map(|a| a.trim_matches('\'').trim_start_matches('@'))
.find(|a| a.contains("openidea-classpath"))
.find(|a| a.contains("/classpath/classpath-"))
.unwrap_or_else(|| panic!("no pathing jar / argfile in {first}"));
assert!(!Path::new(file).exists(), "{file} not deleted");
}
+6 -4
Переглянути файл
@@ -28,8 +28,8 @@ fn workspace(cfg: &LanguageServerConfig) -> Option<&Path> {
cfg.args.iter().position(|a| a == "-data").and_then(|i| cfg.args.get(i + 1)).map(Path::new)
}
/// jdtls' temporary folder for `workspace`: `<workspace>/.tmp`, or a folder of its own in the
/// system temporary folder when the workspace path has whitespace (macOS's `Application Support`).
/// jdtls' temporary folder for `workspace`: `<workspace>/.tmp`, or a folder of its own in this
/// user's temporary folder when the workspace path has whitespace (macOS's `Application Support`).
/// Buildship writes its Gradle init script there and later splits the stored arguments at spaces,
/// so a path with a space reaches Gradle cut off and every Gradle import fails.
fn temp_dir(workspace: &Path) -> PathBuf {
@@ -42,8 +42,10 @@ fn temp_dir(workspace: &Path) -> PathBuf {
.to_string_lossy()
.bytes()
.fold(0xcbf2_9ce4_8422_2325_u64, |h, b| (h ^ u64::from(b)).wrapping_mul(0x0100_0000_01b3));
let shared = std::env::temp_dir().join(format!("openidea-jdtls-{hash:016x}"));
if has_whitespace(&shared) { own } else { shared }
match ide_core::private_temp::dir("jdtls") {
Ok(dir) if !has_whitespace(&dir) => dir.join(format!("{hash:016x}")),
_ => own,
}
}
fn has_whitespace(path: &Path) -> bool {
+4 -3
Переглянути файл
@@ -116,9 +116,10 @@ fn jdk_tool(name: &str, jdks: &[crate::java::Jdk]) -> Option<PathBuf> {
Some(jdk.home.join("bin").join(crate::exe(name))).filter(|p| p.is_file())
}
/// Directory for binaries compiled from single source files (`rustc`, `clang`).
pub fn compile_dir() -> PathBuf {
std::env::temp_dir().join("openidea-run")
/// Directory for binaries compiled from single source files (`rustc`, `clang`): a folder of this
/// user, as the binaries in it are run.
pub fn compile_dir() -> std::io::Result<PathBuf> {
ide_core::private_temp::dir("run")
}
/// The macOS SDK to pass to `clang -isysroot`. A newer compiler (e.g. Homebrew LLVM)
+4 -9
Переглянути файл
@@ -178,15 +178,11 @@ const POWERSHELL_ARGS: [&str; 5] = ["-ExecutionPolicy", "Bypass", "-NoExit", "-C
/// Directory holding the generated startup files (written on demand). Keyed by the scripts'
/// content as well as the version, so builds with different scripts (a dev build next to a
/// release, two checkouts on one machine) never rewrite each other's files under a starting shell.
fn scripts_dir() -> PathBuf {
fn scripts_dir() -> std::io::Result<PathBuf> {
use std::hash::{Hash, Hasher};
let mut hasher = std::hash::DefaultHasher::new();
(ZSHENV, ZPROFILE, ZSHRC, ZLOGIN, BASHRC).hash(&mut hasher);
std::env::temp_dir().join(format!(
"openidea-shell-integration-{}-{:016x}",
env!("CARGO_PKG_VERSION"),
hasher.finish()
))
ide_core::private_temp::dir(&format!("shell-integration-{}-{:016x}", env!("CARGO_PKG_VERSION"), hasher.finish()))
}
/// Writes through a temporary file and a rename, so a shell (or another process doing the
@@ -228,10 +224,9 @@ pub(crate) fn apply(shell_name: &str, args: &mut Vec<String>, env: &mut BTreeMap
return false;
}
let shell_name = if windows_bash { "bash" } else { shell_name };
let dir = scripts_dir();
let result = match shell_name {
"zsh" => (|| -> std::io::Result<()> {
let zdir = dir.join("zsh");
let zdir = scripts_dir()?.join("zsh");
write_if_changed(&zdir.join(".zshenv"), ZSHENV)?;
write_if_changed(&zdir.join(".zprofile"), ZPROFILE)?;
write_if_changed(&zdir.join(".zshrc"), ZSHRC)?;
@@ -249,7 +244,7 @@ pub(crate) fn apply(shell_name: &str, args: &mut Vec<String>, env: &mut BTreeMap
return false;
}
(|| -> std::io::Result<()> {
let rc = dir.join("bash").join("openidea.bashrc");
let rc = scripts_dir()?.join("bash").join("openidea.bashrc");
write_if_changed(&rc, BASHRC)?;
if args.iter().any(|a| a == "-l" || a == "--login") {
env.insert("OPENIDEA_LOGIN".into(), "1".into());