Reimplement boolean environment variables, properly this time

This commit is contained in:
timvisee 2018-05-17 17:31:40 +02:00
parent a644792259
commit 70bbf02762
No known key found for this signature in database
GPG key ID: 109CBA0BF74036C2
4 changed files with 18 additions and 12 deletions

View file

@ -6,9 +6,10 @@ extern crate fs2;
extern crate open;
use std::borrow::Borrow;
use std::env::current_exe;
use std::env::{current_exe, var_os};
#[cfg(feature = "clipboard")]
use std::error::Error as StdError;
use std::ffi::OsStr;
use std::fmt::{Debug, Display};
use std::io::{
Error as IoError,
@ -633,3 +634,10 @@ pub fn app_history_file_path_string() -> String {
.unwrap()
.to_owned()
}
/// Check whether an environment variable with the given key is present in the context of the
/// current process. The environment variable doesn't have to hold any specific value.
/// Returns `true` if present, `false` if not.
pub fn env_var_present(key: impl AsRef<OsStr>) -> bool {
var_os(key).is_some()
}