Skip to content
Prev Previous commit
Next Next commit
Change os.proc.env to os.SubProcess.env
  • Loading branch information
lolgab committed Aug 30, 2024
commit 9db0b1d2482d577252a412f0c2ab1721a05709ea
3 changes: 1 addition & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ trait MiMaChecks extends Mima {
override def mimaBinaryIssueFilters: T[Seq[ProblemFilter]] = Seq(
ProblemFilter.exclude[ReversedMissingMethodProblem]("os.PathConvertible.isCustomFs"),
// this is fine, because ProcessLike is sealed (and its subclasses should be final)
ProblemFilter.exclude[ReversedMissingMethodProblem]("os.ProcessLike.joinPumperThreadsHook"),
ProblemFilter.exclude[MissingTypesProblem]("os.proc$")
ProblemFilter.exclude[ReversedMissingMethodProblem]("os.ProcessLike.joinPumperThreadsHook")
)
}

Expand Down
15 changes: 1 addition & 14 deletions os/src/ProcessOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,6 @@ case class proc(command: Shellable*) {
def pipeTo(next: proc): ProcGroup = ProcGroup(Seq(this, next))
}

object proc {

/**
* The env passed by default to child processes
*/
val env = new scala.util.DynamicVariable[Map[String, String]](sys.env)

// TODO: Delete when in binary compatibity breaking window
def andThen[T](f: proc => T): Seq[Shellable] => T = s => f(apply(s))
// TODO: Delete when in binary compatibity breaking window
def compose[T](f: T => Seq[Shellable]): T => proc = t => apply(f(t))
}

/**
* A group of processes that are piped together, corresponding to e.g. `ls -l | grep .scala`.
* You can create a `ProcGroup` by calling `.pipeTo` on a [[proc]] multiple times.
Expand Down Expand Up @@ -509,7 +496,7 @@ private[os] object ProcessOps {
}

if (propagateEnv) {
addToProcessEnv(os.proc.env.value)
addToProcessEnv(os.SubProcess.env.value)
}

addToProcessEnv(env)
Expand Down
5 changes: 5 additions & 0 deletions os/src/SubProcess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ class SubProcess(

object SubProcess {

/**
* The env passed by default to child processes
*/
val env = new scala.util.DynamicVariable[Map[String, String]](sys.env)

/**
* A [[BufferedWriter]] with the underlying [[java.io.OutputStream]] exposed
*
Expand Down
2 changes: 1 addition & 1 deletion os/test/src/SubprocessTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object SubprocessTests extends TestSuite {
val before = envValue()
assert(before == "")

os.proc.env.withValue(Map("TEST_ENV_FOO" -> "bar")) {
os.SubProcess.env.withValue(Map("TEST_ENV_FOO" -> "bar")) {
val res = envValue()
assert(res == "bar")
}
Expand Down