summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-10-31 16:24:51 +0100
committerGitHub <noreply@github.com>2017-10-31 16:24:51 +0100
commit23820e322e8693321ca9c3800b9100456d241cbe (patch)
tree30a65af68356924482b6c2f88ca5a0974a7ad0ec
parentdc26f8c20cd9724201ee5bd60a22d3e422b56e7c (diff)
parent4250241f1856f31832edaad98dbdbb6b6cdf4cd8 (diff)
downloadimag-23820e322e8693321ca9c3800b9100456d241cbe.zip
imag-23820e322e8693321ca9c3800b9100456d241cbe.tar.gz
Merge pull request #1157 from matthiasbeyer/imag-location-from-env
Try to get RTP from IMAG_RTP
-rw-r--r--doc/src/09020-changelog.md2
-rw-r--r--lib/core/libimagrt/src/runtime.rs22
2 files changed, 16 insertions, 8 deletions
diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md
index baa9e0d..d6e60eb 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 8e80572..42f5d5b 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)
}