]> git.lizzy.rs Git - rust.git/commit
io::process::Command: add fine-grained env builder
authorAaron Turon <aturon@mozilla.com>
Wed, 2 Jul 2014 20:50:45 +0000 (13:50 -0700)
committerAaron Turon <aturon@mozilla.com>
Thu, 10 Jul 2014 19:16:16 +0000 (12:16 -0700)
commitbfa853f8ed45d1908c98ec350f52c7a6790661da
tree96c101298ae0503bd64bb51201e2154eeb88d905
parentf9fe251777e9f1cc557a6d5b82b45403935d0a10
io::process::Command: add fine-grained env builder

This commit changes the `io::process::Command` API to provide
fine-grained control over the environment:

* The `env` method now inserts/updates a key/value pair.
* The `env_remove` method removes a key from the environment.
* The old `env` method, which sets the entire environment in one shot,
  is renamed to `env_set_all`. It can be used in conjunction with the
  finer-grained methods. This renaming is a breaking change.

To support these new methods, the internal `env` representation for
`Command` has been changed to an optional `HashMap` holding owned
`CString`s (to support non-utf8 data). The `HashMap` is only
materialized if the environment is updated. The implementation does not
try hard to avoid allocation, since the cost of launching a process will
dwarf any allocation cost.

This patch also adds `PartialOrd`, `Eq`, and `Hash` implementations for
`CString`.

[breaking-change]
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/libnative/io/process.rs
src/librustdoc/test.rs
src/librustrt/c_str.rs
src/librustrt/lib.rs
src/librustrt/rtio.rs
src/librustuv/process.rs
src/libstd/io/process.rs
src/test/run-pass/backtrace.rs
src/test/run-pass/process-spawn-with-unicode-params.rs