Re: [patch] gdb/testsuite: Fix POSIX-isms in gdb.base/shell.exp

Sandra Loosemore
2020-06-25T17:57:16Z

On 6/25/20 11:32 AM, Christian Biesinger wrote:
> On Wed, Jun 24, 2020 at 8:35 PM Sandra Loosemore
> <sandra@codesourcery.com> wrote:
>>
>> This patch fixes a group of failures in gdb.base/shell.exp on Windows
>> host due to assumptions that GDB is launching a POSIX-like shell. On
>> Windows, we get CMD.EXE instead.
>
> Hmm, if I call runtest/make check from an msys2 shell, do I really get
> cmd.exe here? I ask because i wonder how many people run this from
> cmd.exe as opposed to msys's shell, so it may be better to check for
> cmd more specifically somehow (maybe $SHELL?)

I'm not familiar with the msys2 shell, but....

On Windows host GDB uses the system() function provided by the host C
library to launch a shell and does not consult $SHELL at all. This is
in shell_escape in gdb/cli/cli-cmds.c.

Here is the documentation I found via Google for system() in the Windows
library:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/system-wsystem?view=vs-2019

"system uses the COMSPEC and PATH environment variables to locate the
command-interpreter file CMD.exe."

I think the GDB manual doesn't accurately describe what GDB does in this
situation, BTW.

-Sandra