There's:
scala> util.Properties.envOrNone("PATH") res0: Option[String] = Some(/home/apm/go1.1/go/bin:/home/apm/go/bin:/home/apm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games)
That is:
scala> util.Properties.envOrSome("PATH", Some("")) map (p => s"$p${new sys.SystemProperties()("path.separator")}/tmp") get warning: there was one feature warning; re-run with -feature for details res5: String = /home/apm/go1.1/go/bin:/home/apm/go/bin:/home/apm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/tmp
I just noticed my PATH has gone stale.
Edit for idiom:
scala> def appendToEnv(key: String, value: String) = util.Properties.envOrNone(key) match { | case Some(v) if v.nonEmpty => s"$v${System getProperty "path.separator"}$value" | case _ => value | } appendToEnv: (key: String, value: String)String scala> appendToEnv("PATH", "/opt") res0: String = /home/apm/go1.1/go/bin:/home/apm/go/bin:/home/apm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt scala> appendToEnv("UNPATH", "/opt") res1: String = /opt