Skip to content

Commit e92473f

Browse files
committed
pwd: introduce IS_POSIXLY_CORRECT static
1 parent f42b620 commit e92473f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/uu/pwd/src/pwd.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use clap::{Arg, Command};
88
use std::env;
99
use std::io;
1010
use std::path::PathBuf;
11+
use std::sync::LazyLock;
1112
use uucore::format_usage;
1213

1314
use uucore::display::println_verbatim;
@@ -115,7 +116,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
115116
// We should get c in this case instead of a/b at the end of the path
116117
let cwd = if matches.get_flag(OPT_PHYSICAL) {
117118
physical_path()
118-
} else if matches.get_flag(OPT_LOGICAL) || env::var("POSIXLY_CORRECT").is_ok() {
119+
} else if matches.get_flag(OPT_LOGICAL) || *IS_POSIXLY_CORRECT {
119120
logical_path()
120121
} else {
121122
physical_path()
@@ -161,3 +162,6 @@ pub fn uu_app() -> Command {
161162
.action(ArgAction::SetTrue),
162163
)
163164
}
165+
166+
static IS_POSIXLY_CORRECT: LazyLock<bool> =
167+
LazyLock::new(|| env::var_os("POSIXLY_CORRECT").is_some());

0 commit comments

Comments
 (0)