mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
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:
@@ -50,6 +50,7 @@
|
||||
#include "cli/cli-utils.h"
|
||||
|
||||
#include "extension.h"
|
||||
#include "common/pathstuff.h"
|
||||
|
||||
#ifdef TUI
|
||||
#include "tui/tui.h" /* For tui_active et.al. */
|
||||
@@ -726,13 +727,10 @@ shell_escape (const char *arg, int from_tty)
|
||||
|
||||
if ((pid = vfork ()) == 0)
|
||||
{
|
||||
const char *p, *user_shell;
|
||||
const char *p, *user_shell = get_shell ();
|
||||
|
||||
close_most_fds ();
|
||||
|
||||
if ((user_shell = getenv ("SHELL")) == NULL)
|
||||
user_shell = "/bin/sh";
|
||||
|
||||
/* Get the name of the shell for arg0. */
|
||||
p = lbasename (user_shell);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user