diff --git a/Readme.adoc b/Readme.adoc index 4d12f8f2..ce2b2723 100644 --- a/Readme.adoc +++ b/Readme.adoc @@ -1815,7 +1815,7 @@ wd / os.up wd / os.up / os.up ---- -`os.pwd` can be modified in certain scopes via the `os.pwd0` dynamic variable, but +`os.pwd` can be modified in certain scopes via the `os.dynamicPwd` dynamic variable, but best practice is not to change it. Instead simply define a new path, e.g. [source,scala] diff --git a/os/src-jvm/package.scala b/os/src-jvm/package.scala index 0dc7623b..d11a54d6 100644 --- a/os/src-jvm/package.scala +++ b/os/src-jvm/package.scala @@ -39,8 +39,8 @@ package object os { /** * The current working directory for this process. */ - def pwd: Path = pwd0.value - val pwd0: DynamicVariable[Path] = + def pwd: Path = dynamicPwd.value + val dynamicPwd: DynamicVariable[Path] = new DynamicVariable(os.Path(java.nio.file.Paths.get(".").toAbsolutePath)) val up: RelPath = RelPath.up diff --git a/os/src-native/package.scala b/os/src-native/package.scala index 89057268..e71aac1a 100644 --- a/os/src-native/package.scala +++ b/os/src-native/package.scala @@ -32,8 +32,8 @@ package object os { /** * The current working directory for this process. */ - def pwd: Path = pwd0.value - val pwd0: DynamicVariable[Path] = + def pwd: Path = dynamicPwd.value + val dynamicPwd: DynamicVariable[Path] = new DynamicVariable(os.Path(java.nio.file.Paths.get(".").toAbsolutePath)) val up: RelPath = RelPath.up diff --git a/os/test/src/PathTests.scala b/os/test/src/PathTests.scala index 67f005d2..365b1647 100644 --- a/os/test/src/PathTests.scala +++ b/os/test/src/PathTests.scala @@ -434,9 +434,9 @@ object PathTests extends TestSuite { System.err.printf("p[%s]\n", posix(p)) assert(posix(p) contains "/omg") } - test("pwd0") { + test("dynamicPwd") { val x = os.pwd - val y = os.pwd0.withValue(os.pwd / "hello") { + val y = os.dynamicPwd.withValue(os.pwd / "hello") { os.pwd } diff --git a/os/test/src/SubprocessTests.scala b/os/test/src/SubprocessTests.scala index f154de6a..a3bf96d1 100644 --- a/os/test/src/SubprocessTests.scala +++ b/os/test/src/SubprocessTests.scala @@ -203,7 +203,7 @@ object SubprocessTests extends TestSuite { assert(output.out.lines() == Seq("HELLO /usr")) } } - test("pwd0") { + test("dynamicPwd") { // Windows doesnt have bash installed so a bit inconvenient // to run these subprocesses for testing if (!scala.util.Properties.isWin) { @@ -211,7 +211,7 @@ object SubprocessTests extends TestSuite { val tmp0 = os.temp.dir() val tmp = os.followLink(tmp0).getOrElse(tmp0) val x = proc("bash", "-c", "pwd").call() - val y = os.pwd0.withValue(tmp) { + val y = os.dynamicPwd.withValue(tmp) { proc("bash", "-c", "pwd").call() }