File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 28
28
inDir : (NSString *) dir
29
29
inputString : (NSString *)input
30
30
retValue : (int *) ret ;
31
+ + (NSString *) outputForCommand : (NSString *) cmd
32
+ withArgs : (NSArray *) args
33
+ inDir : (NSString *) dir
34
+ byExtendingEnvironment : (NSDictionary *)dict
35
+ inputString : (NSString *)input
36
+ retValue : (int *) ret ;
37
+
31
38
32
39
@end
Original file line number Diff line number Diff line change @@ -51,17 +51,33 @@ + (NSString*) outputForCommand:(NSString *) cmd
51
51
inDir : (NSString *) dir
52
52
retValue : (int *) ret
53
53
{
54
- return [self outputForCommand: cmd withArgs: args inDir: dir inputString: NULL retValue: ret];
54
+ return [self outputForCommand: cmd withArgs: args inDir: dir byExtendingEnvironment: nil inputString: nil retValue: ret];
55
55
}
56
56
57
- // TODO: Refactor this to use the function above
58
57
+ (NSString *) outputForCommand : (NSString *) cmd
59
58
withArgs : (NSArray *) args
60
59
inDir : (NSString *) dir
61
- inputString : (NSString *)input
60
+ inputString : (NSString *) input
62
61
retValue : (int *) ret
62
+ {
63
+ return [self outputForCommand: cmd withArgs: args inDir: dir byExtendingEnvironment: nil inputString: input retValue: ret];
64
+ }
65
+
66
+ + (NSString *) outputForCommand : (NSString *) cmd
67
+ withArgs : (NSArray *) args
68
+ inDir : (NSString *) dir
69
+ byExtendingEnvironment : (NSDictionary *)dict
70
+ inputString : (NSString *) input
71
+ retValue : (int *) ret
63
72
{
64
73
NSTask *task = [self taskForCommand: cmd withArgs: args inDir: dir];
74
+
75
+ if (dict) {
76
+ NSMutableDictionary *env = [[[NSProcessInfo processInfo ] environment ] mutableCopy ];
77
+ [env addEntriesFromDictionary: dict];
78
+ task.environment = env;
79
+ }
80
+
65
81
NSFileHandle * handle = [task.standardOutput fileHandleForReading ];
66
82
67
83
if (input) {
You can’t perform that action at this time.
0 commit comments