Commit cb4bbc95 authored by Drew's avatar Drew

Update to Swift Preview 5

parent 361b47bd
Subproject commit 6fdd57f7daa08b9ab19fced0392aeeb3edc87d9d Subproject commit b8f458526644c02ad39e46099def2ad5b53514af
...@@ -110,11 +110,14 @@ func waitpid(_ pid: pid_t) -> Int32 { ...@@ -110,11 +110,14 @@ func waitpid(_ pid: pid_t) -> Int32 {
///Rather than calls that aren't ///Rather than calls that aren't
func anarchySystem(_ cmd: String, environment: [String: String]) { func anarchySystem(_ cmd: String, environment: [String: String]) {
var pid : pid_t = 0 var pid : pid_t = 0
//copy PATH //copy a few well-known values
let path = getenv("PATH")!
var environment = environment var environment = environment
environment["PATH"] = String(validatingUTF8: path)! for arg in ["PATH","HOME"] {
if let path = getenv(arg) {
environment[arg] = String(validatingUTF8: path)!
}
}
let args: [String] = ["sh","-c",cmd] let args: [String] = ["sh","-c",cmd]
let argv = args.map{ $0.withCString(strdup) } let argv = args.map{ $0.withCString(strdup) }
let env: [UnsafeMutablePointer<CChar>?] = environment.map{ "\($0.0)=\($0.1)".withCString(strdup) } let env: [UnsafeMutablePointer<CChar>?] = environment.map{ "\($0.0)=\($0.1)".withCString(strdup) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment