Merge pull request #1157 from matthiasbeyer/imag-location-from-env

Try to get RTP from IMAG_RTP
This commit is contained in:
Matthias Beyer 2017-10-31 16:24:51 +01:00 committed by GitHub
commit 23820e322e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View file

@ -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

View file

@ -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 \
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.");
})
accommodation anyways."),
}
}, PathBuf::from)
}