Unify shell-finding logic

I noticed several places in gdb that were using getenv("SHELL") and
then falling back to "/bin/sh" if it returned NULL.  This unifies
these into a single function.

gdb/ChangeLog
2018-10-27  Tom Tromey  <tom@tromey.com>

	* procfs.c (procfs_target::create_inferior): Use get_shell.
	* cli/cli-cmds.c (shell_escape): Use get_shell.
	* windows-nat.c (windows_nat_target::create_inferior): Use
	get_shell.
	* common/pathstuff.c (get_shell): New function.
	* nat/fork-inferior.c (SHELL_FILE, get_startup_shell): Remove.
	(fork_inferior): Use get_shell.
	* common/pathstuff.h (get_shell): Declare.
This commit is contained in:
Tom Tromey
2018-09-14 10:35:45 -06:00
parent c8ee3f04a6
commit 974e684463
7 changed files with 36 additions and 28 deletions

View File

@@ -3035,11 +3035,11 @@ procfs_target::create_inferior (const char *exec_file,
const std::string &allargs,
char **env, int from_tty)
{
char *shell_file = getenv ("SHELL");
const char *shell_file = get_shell ();
char *tryname;
int pid;
if (shell_file != NULL && strchr (shell_file, '/') == NULL)
if (strchr (shell_file, '/') == NULL)
{
/* We will be looking down the PATH to find shell_file. If we