mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
pwd: support the env variable 'POSIXLY_CORRECT'
Should fix tests/misc/pwd-option.sh
This commit is contained in:
@@ -126,7 +126,10 @@ fn logical_path() -> io::Result<PathBuf> {
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
let cwd = if matches.get_flag(OPT_LOGICAL) {
|
||||
// if POSIXLY_CORRECT is set, we want to a logical resolution.
|
||||
// This produces a different output when doing mkdir -p a/b && ln -s a/b c && cd c && pwd
|
||||
// We should get c in this case instead of a/b at the end of the path
|
||||
let cwd = if matches.get_flag(OPT_LOGICAL) || env::var("POSIXLY_CORRECT").is_ok() {
|
||||
logical_path()
|
||||
} else {
|
||||
physical_path()
|
||||
|
||||
@@ -90,6 +90,35 @@ fn test_symlinked_default() {
|
||||
env.ucmd.succeeds().stdout_is(env.subdir + "\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_symlinked_default_posix() {
|
||||
let mut env = symlinked_env();
|
||||
env.ucmd
|
||||
.env("POSIXLY_CORRECT", "1")
|
||||
.succeeds()
|
||||
.stdout_is(env.symdir.clone() + "\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_symlinked_default_posix_l() {
|
||||
let mut env = symlinked_env();
|
||||
env.ucmd
|
||||
.env("POSIXLY_CORRECT", "1")
|
||||
.arg("-L")
|
||||
.succeeds()
|
||||
.stdout_is(env.symdir + "\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_symlinked_default_posix_p() {
|
||||
let mut env = symlinked_env();
|
||||
env.ucmd
|
||||
.env("POSIXLY_CORRECT", "1")
|
||||
.arg("-P")
|
||||
.succeeds()
|
||||
.stdout_is(env.symdir + "\n");
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub mod untrustworthy_pwd_var {
|
||||
use std::path::Path;
|
||||
|
||||
Reference in New Issue
Block a user