Function find_as_string

Source
pub fn find_as_string(name: &str) -> Option<CString>
Expand description

Returns a string with the value of the shell variable name.

If the shell variable does not exist, or its value is an array, the function returns None.

ยงExample

use bash_builtins::variables;

let var = variables::find_as_string("VAR_NAME");

if let Some(value) = var.as_ref().and_then(|v| v.to_str().ok()) {
    // `value` is a `&str` here.
} else {
    // `$VAR_NAME` is missing, an array, or contains
    // invalid UTF-8 data.
}