Skip to content

Commit cc4b2e2

Browse files
authored
Merge pull request #63 from Carthage/fix-task-description
Quote whitespace-containing arguments in Task.description
2 parents 375d21f + 9e4b12e commit cc4b2e2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ReactiveTask/Task.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,19 @@ public struct Task {
4646
}
4747
}
4848

49+
private extension String {
50+
var escaped: String {
51+
if rangeOfCharacterFromSet(.whitespaceCharacterSet()) != nil {
52+
return "\"\(self)\""
53+
} else {
54+
return self
55+
}
56+
}
57+
}
58+
4959
extension Task: CustomStringConvertible {
5060
public var description: String {
51-
return "\(launchPath) \(arguments.joinWithSeparator(" "))"
61+
return "\(launchPath) \(arguments.map { $0.escaped }.joinWithSeparator(" "))"
5262
}
5363
}
5464

0 commit comments

Comments
 (0)