Skip to content

Instantly share code, notes, and snippets.

@JorgenEvens
Created August 1, 2013 07:39
Show Gist options
  • Save JorgenEvens/6129245 to your computer and use it in GitHub Desktop.
Save JorgenEvens/6129245 to your computer and use it in GitHub Desktop.
Sets custom environment variables before the shell starts. Was usefull as a workaround to get TERM=xterm-color inject when using terminator on ubuntu.
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char **argv) {
char* shell = getenv("SHELL");
if( shell == NULL )
shell = "bash";
char* param[2];
param[0] = shell;
param[1] = NULL;
int i = 0;
for( i=0; i<argc; i++ ) {
putenv(argv[i]);
}
execvp(shell, param);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment