From 4250241f1856f31832edaad98dbdbb6b6cdf4cd8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 31 Oct 2017 15:29:45 +0100 Subject: [PATCH] Try to get RTP from IMAG_RTP --- doc/src/09020-changelog.md | 2 ++ lib/core/libimagrt/src/runtime.rs | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index baa9e0d6..d6e60ebe 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -38,6 +38,8 @@ This section contains the changelog from the last release to the next release. * `libimagentryannotation` got a rewrite, is not based on `libimagnotes` anymore. This is minor because `libimagentryanntation` is not yet used by any other crate. + * imag now reads the `IMAG_RTP` environment variable before trying to access + `$HOME/.imag` for its runtimepath. * Bugfixes * `Store::entries()` does not yield StoreIds which point to directories diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs index 8e805723..42f5d5ba 100644 --- a/lib/core/libimagrt/src/runtime.rs +++ b/lib/core/libimagrt/src/runtime.rs @@ -454,14 +454,20 @@ fn get_rtp_match<'a>(matches: &ArgMatches<'a>) -> PathBuf { matches.value_of(Runtime::arg_runtimepath_name()) .map_or_else(|| { - env::var("HOME") - .map(PathBuf::from) - .map(|mut p| { p.push(".imag"); p }) - .unwrap_or_else(|_| { - panic!("You seem to be $HOME-less. Please get a $HOME before using this \ - software. We are sorry for you and hope you have some \ - accommodation anyways."); - }) + if let Ok(home) = env::var("IMAG_RTP") { + return PathBuf::from(home); + } + + match env::var("HOME") { + Ok(home) => { + let mut p = PathBuf::from(home); + p.push(".imag"); + return p; + }, + Err(_) => panic!("You seem to be $HOME-less. Please get a $HOME before using this \ + software. We are sorry for you and hope you have some \ + accommodation anyways."), + } }, PathBuf::from) }