1 /* Functions to deal with the inferior being executed on GDB or
4 Copyright (C) 2019-2020 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "gdbsupport/common-defs.h"
22 #include "gdbsupport/common-inferior.h"
24 /* See common-inferior.h. */
26 bool startup_with_shell
= true;
28 /* See common-inferior.h. */
31 construct_inferior_arguments (int argc
, char * const *argv
)
33 gdb_assert (argc
>= 0);
37 if (startup_with_shell
)
40 /* This holds all the characters considered special to the
42 static const char special
[] = "\"!&*|[]{}<>?`~^=;, \t\n";
43 static const char quote
= '"';
45 /* This holds all the characters considered special to the
46 typical Unix shells. We include `^' because the SunOS
47 /bin/sh treats it as a synonym for `|'. */
48 static const char special
[] = "\"!#$&*()\\|[]{}<>?'`~^; \t\n";
49 static const char quote
= '\'';
51 for (int i
= 0; i
< argc
; ++i
)
56 /* Need to handle empty arguments specially. */
57 if (argv
[i
][0] == '\0')
67 if (strpbrk (argv
[i
], special
))
73 for (char *cp
= argv
[i
]; *cp
; ++cp
)
77 /* A newline cannot be quoted with a backslash (it
78 just disappears), only by putting it inside
89 if (strchr (special
, *cp
) != NULL
)
104 /* In this case we can't handle arguments that contain spaces,
105 tabs, or newlines -- see breakup_args(). */
106 for (int i
= 0; i
< argc
; ++i
)
108 char *cp
= strchr (argv
[i
], ' ');
110 cp
= strchr (argv
[i
], '\t');
112 cp
= strchr (argv
[i
], '\n');
114 error (_("can't handle command-line "
115 "argument containing whitespace"));
118 for (int i
= 0; i
< argc
; ++i
)
This page took 0.034202 seconds and 4 git commands to generate.