@@ -71,51 +71,63 @@ - (NSFileHandle*) handleForArguments:(NSArray *)args
71
71
- (NSString *) outputForCommand : (NSString *)cmd
72
72
{
73
73
NSArray * arguments = [cmd componentsSeparatedByString: @" " ];
74
- return [self outputForArguments: arguments];
74
+ return [self outputForArguments: arguments inputString: nil byExtendingEnvironment: nil retValue: NULL ];
75
75
}
76
76
77
77
- (NSString *) outputForCommand : (NSString *)str retValue : (int *)ret ;
78
78
{
79
79
NSArray * arguments = [str componentsSeparatedByString: @" " ];
80
- return [self outputForArguments: arguments retValue: ret];
80
+ return [self outputForArguments: arguments inputString: nil byExtendingEnvironment: nil retValue: ret];
81
81
}
82
82
83
83
- (NSString *) outputForArguments : (NSArray *) arguments
84
84
{
85
- return [PBEasyPipe outputForCommand: [PBGitBinary path ] withArgs: arguments inDir: self .workingDirectory ];
85
+ return [self outputForArguments: arguments inputString: nil byExtendingEnvironment: nil retValue: NULL ];
86
86
}
87
87
88
88
- (NSString *) outputInWorkdirForArguments : (NSArray *) arguments
89
89
{
90
- return [PBEasyPipe outputForCommand: [PBGitBinary path ] withArgs: arguments inDir: self .workingDirectory ];
90
+ return [self outputForArguments: arguments inputString: nil byExtendingEnvironment: nil retValue: NULL ];
91
91
}
92
92
93
93
- (NSString *) outputInWorkdirForArguments : (NSArray *)arguments retValue : (int *)ret
94
94
{
95
- return [PBEasyPipe outputForCommand: [PBGitBinary path ] withArgs: arguments inDir: self .workingDirectory retValue: ret];
95
+ return [self outputForArguments: arguments inputString: nil byExtendingEnvironment: nil retValue: ret];
96
96
}
97
97
98
98
- (NSString *) outputForArguments : (NSArray *)arguments retValue : (int *)ret
99
99
{
100
- return [PBEasyPipe outputForCommand: [PBGitBinary path ] withArgs: arguments inDir: self .workingDirectory retValue: ret];
100
+ return [self outputForArguments: arguments inputString: nil byExtendingEnvironment: nil retValue: ret];
101
101
}
102
102
103
103
- (NSString *) outputForArguments : (NSArray *)arguments inputString : (NSString *)input retValue : (int *)ret
104
104
{
105
- return [PBEasyPipe outputForCommand: [PBGitBinary path ]
106
- withArgs: arguments
107
- inDir: self .workingDirectory
108
- inputString: input
109
- retValue: ret];
105
+ return [self outputForArguments: arguments inputString: input byExtendingEnvironment: nil retValue: ret];
110
106
}
111
107
112
108
- (NSString *)outputForArguments : (NSArray *)arguments inputString : (NSString *)input byExtendingEnvironment : (NSDictionary *)dict retValue : (int *)ret
113
109
{
114
- return [PBEasyPipe outputForCommand: [PBGitBinary path ]
115
- withArgs: arguments
116
- inDir: self .workingDirectory
117
- byExtendingEnvironment: dict
118
- inputString: input
119
- retValue: ret];
110
+ PBTask *task = [self taskWithArguments: arguments];
111
+ if (input)
112
+ task.standardInputData = [input dataUsingEncoding: NSUTF8StringEncoding];
113
+ if (dict)
114
+ task.additionalEnvironment = dict;
115
+
116
+ NSError *error = nil ;
117
+ BOOL success = [task launchTask: &error];
118
+ if (!success) {
119
+ PBLogError (error);
120
+ NSNumber *status;
121
+ if (ret && (status = error.userInfo [PBTaskTerminationStatusKey])) {
122
+ *ret = [status intValue ];
123
+ } else if (ret) {
124
+ *ret = 1 ;
125
+ }
126
+
127
+ return nil ;
128
+ }
129
+ if (ret) *ret = 0 ;
130
+
131
+ return task.standardOutputString ;
120
132
}
121
133
@end
0 commit comments