Skip to content

Commit

Permalink
Set SHELL environment variable.
Browse files Browse the repository at this point in the history
* Set the SHELL environment variable to the user's configured
shell.
  • Loading branch information
j-c-m committed Feb 10, 2019
1 parent b6b5122 commit b5219d2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/wslbridge-backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ int main(int argc, char *argv[]) {
}
if (childParams.argv.empty()) {
const char *shell = "/bin/sh";
char *shellEnv;
struct passwd *pw = getpwuid(getuid());
if (pw == nullptr) {
fatalPerror("error: getpwuid failed");
Expand All @@ -580,6 +581,10 @@ int main(int argc, char *argv[]) {
} else {
shell = pw->pw_shell;
}
if (asprintf(&shellEnv, "SHELL=%s", shell) == -1) {
fatal("error: unable to set shellEnv\n");
}
childParams.env.push_back(shellEnv);
childParams.argv.push_back(strdup(shell));
}
// XXX: Replace char* args/envstrings with std::string?
Expand Down

0 comments on commit b5219d2

Please sign in to comment.