Merge pull request #161 from matthiasbeyer/libimagrt/fix-160
Fix: Use env(HOME) instead of "~"
This commit is contained in:
commit
ec01bafcf1
1 changed files with 12 additions and 1 deletions
|
@ -32,8 +32,19 @@ impl<'a> Runtime<'a> {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
pub fn new(cli_spec: App<'a, 'a, 'a, 'a, 'a, 'a>) -> Result<Runtime<'a>, RuntimeError> {
|
pub fn new(cli_spec: App<'a, 'a, 'a, 'a, 'a, 'a>) -> Result<Runtime<'a>, RuntimeError> {
|
||||||
|
use std::env;
|
||||||
|
|
||||||
let matches = cli_spec.get_matches();
|
let matches = cli_spec.get_matches();
|
||||||
let rtp : PathBuf = matches.value_of("runtimepath").unwrap_or("~/.imag/").into();
|
let rtp : PathBuf = matches.value_of("runtimepath")
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_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.");
|
||||||
|
})
|
||||||
|
});
|
||||||
let storepath = matches.value_of("storepath")
|
let storepath = matches.value_of("storepath")
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.unwrap_or({
|
.unwrap_or({
|
||||||
|
|
Loading…
Reference in a new issue