mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 11:37:32 +03:00
GH-664 Extract env vars correctly
This commit is contained in:
parent
8e362111d3
commit
01a7f119ee
@ -19,7 +19,8 @@ class ProcessUtils {
|
|||||||
shellArgs.append("-i")
|
shellArgs.append("-i")
|
||||||
}
|
}
|
||||||
|
|
||||||
shellArgs.append(contentsOf: ["-c", "env"])
|
let marker = UUID().uuidString
|
||||||
|
shellArgs.append(contentsOf: ["-c", "echo \(marker) && env"])
|
||||||
|
|
||||||
let outputPipe = Pipe()
|
let outputPipe = Pipe()
|
||||||
let errorPipe = Pipe()
|
let errorPipe = Pipe()
|
||||||
@ -41,7 +42,12 @@ class ProcessUtils {
|
|||||||
process.terminate()
|
process.terminate()
|
||||||
process.waitUntilExit()
|
process.waitUntilExit()
|
||||||
|
|
||||||
return output
|
guard let range = output.range(of: marker) else {
|
||||||
|
return [:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return output[range.upperBound...]
|
||||||
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
.split(separator: "\n")
|
.split(separator: "\n")
|
||||||
.reduce(into: [:]) { result, entry in
|
.reduce(into: [:]) { result, entry in
|
||||||
let split = entry.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false).map { String($0) }
|
let split = entry.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false).map { String($0) }
|
||||||
|
Loading…
Reference in New Issue
Block a user