aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-14 10:35:45 -0600
committerTom Tromey <tom@tromey.com>2018-10-27 11:58:40 -0600
commit974e68446388769f023c6c9bfb1e67ed75199618 (patch)
tree49cb772e05b3d9157addbfea699624a0f293e969 /gdb/nat
parentRemove a bunch of usages of gdb_suppress_tests in 'runto_main'. (diff)
downloadbinutils-gdb-974e68446388769f023c6c9bfb1e67ed75199618.tar.gz
binutils-gdb-974e68446388769f023c6c9bfb1e67ed75199618.tar.bz2
binutils-gdb-974e68446388769f023c6c9bfb1e67ed75199618.zip
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.
Diffstat (limited to 'gdb/nat')
-rw-r--r--gdb/nat/fork-inferior.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c
index 40cd05a0f8f..f1032b43c9e 100644
--- a/gdb/nat/fork-inferior.c
+++ b/gdb/nat/fork-inferior.c
@@ -24,16 +24,13 @@
#include "target/target.h"
#include "common-inferior.h"
#include "common-gdbthread.h"
+#include "common/pathstuff.h"
#include "signals-state-save-restore.h"
#include "gdb_tilde_expand.h"
#include <vector>
extern char **environ;
-/* Default shell file to be used if 'startup-with-shell' is set but
- $SHELL is not. */
-#define SHELL_FILE "/bin/sh"
-
/* Build the argument vector for execv(3). */
class execv_argv
@@ -265,20 +262,6 @@ execv_argv::init_for_shell (const char *exec_file,
m_argv.push_back (NULL);
}
-/* Return the shell that must be used to startup the inferior. The
- first attempt is the environment variable SHELL; if it is not set,
- then we default to SHELL_FILE. */
-
-static const char *
-get_startup_shell ()
-{
- const char *ret = getenv ("SHELL");
- if (ret == NULL)
- ret = SHELL_FILE;
-
- return ret;
-}
-
/* See nat/fork-inferior.h. */
pid_t
@@ -316,7 +299,7 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs,
/* Figure out what shell to start up the user program under. */
if (shell_file == NULL)
- shell_file = get_startup_shell ();
+ shell_file = get_shell ();
gdb_assert (shell_file != NULL);
}