Skip to content
Snippets Groups Projects
Commit b2841f2f authored by George Nachman's avatar George Nachman
Browse files

Adhoc build 1.0.0.20140617_224912

parent 091a3b64
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -172,6 +172,23 @@ static void HandleSigChld(int n)
return command_;
}
 
- (NSMutableDictionary *)environment {
NSMutableDictionary *result = [NSMutableDictionary dictionary];
extern char **environ;
for (int i = 0; environ[i]; i++) {
NSString *kvp = [NSString stringWithUTF8String:environ[i]];
NSRange equalsRange = [kvp rangeOfString:@"="];
if (equalsRange.location != NSNotFound) {
NSString *key = [kvp substringToIndex:equalsRange.location];
NSString *value = [kvp substringFromIndex:equalsRange.location + 1];
result[key] = value;
} else {
result[kvp] = @"";
}
}
return result;
}
- (void)launchWithPath:(NSString*)progpath
arguments:(NSArray*)args
environment:(NSDictionary*)env
Loading
Loading
@@ -214,22 +231,20 @@ static void HandleSigChld(int n)
}
}
argv[max + 1] = NULL;
const int envsize = env.count;
const char *envKeys[envsize];
const char *envValues[envsize];
// This quiets an analyzer warning about envKeys[i] being uninitialized in setenv().
bzero(envKeys, sizeof(char *) * envsize);
bzero(envValues, sizeof(char *) * envsize);
 
// Copy values from env (our custom environment vars) into envDict
int i = 0;
NSMutableDictionary *environmentDict = [self environment];
for (NSString *k in env) {
NSString *v = [env objectForKey:k];
envKeys[i] = [k UTF8String];
envValues[i] = [v UTF8String];
i++;
environmentDict[k] = env[k];
}
char **environment = malloc(sizeof(char*) * (environmentDict.count + 1));
int i = 0;
for (NSString *k in environmentDict) {
NSString *temp = [NSString stringWithFormat:@"%@=%@", k, environmentDict[k]];
environment[i++] = strdup([temp UTF8String]);
NSLog(@"Environment var %d: %s", i, environment[i - 1]);
}
NSLog(@"argpath=%s", argpath);
environment[i] = NULL;
 
// Note: stringByStandardizingPath will automatically call stringByExpandingTildeInPath.
const char *initialPwd = [[[env objectForKey:@"PWD"] stringByStandardizingPath] UTF8String];
Loading
Loading
@@ -250,10 +265,11 @@ static void HandleSigChld(int n)
}
 
chdir(initialPwd);
for (i = 0; i < envsize; i++) {
// The analyzer warning below is an obvious lie.
setenv(envKeys[i], envValues[i], 1);
}
// Sub in our environ for the existing one. Since Mac OS doesn't have execvpe, this hack
// does the job.
extern char **environ;
environ = environment;
execvp(argpath, (char* const*)argv);
 
/* exec error */
Loading
Loading
@@ -271,6 +287,10 @@ static void HandleSigChld(int n)
nil);
return;
}
for (int j = 0; j < i; j++) {
free(environment[j]);
}
free(environment);
 
// Make sure the master side of the pty is closed on future exec() calls.
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
Loading
Loading
Loading
Loading
@@ -189,12 +189,12 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>iTermApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>SUPublicDSAKeyFile</key>
<string>dsa_pub.pem</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>SUFeedURLForTesting</key>
<string>http://iterm2.com/appcasts/nightly.xml</string>
<string>http://iterm2.com/appcasts/testing.xml</string>
<key>SUFeedURLForFinal</key>
<string>http://iterm2.com/appcasts/final.xml</string>
</dict>
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment