From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DFC5B3858437 for ; Sun, 21 Jan 2024 03:57:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFC5B3858437 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DFC5B3858437 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705809425; cv=none; b=I8VxYfHo7PpTzEJdycLp42Mv16ACFOzOQ8p2Gg4maQaix6d/ZxfsQEIjABb1nQ9f2jrJZS2o9ReQPTHalCznMJ7AP5wj8ngIq+foCCq1DRb4NAnatxsbUtRnDHpALiH/Yo/Q2D3/yXnZ25t6gTeuSrcv7o0M0Gt8JnhLIBtJyw0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705809425; c=relaxed/simple; bh=DPu/tMz4a4S6yT0vLnoKtDlIz8/LS5CGLdm5fJ3X4eI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=oL5fvGfHkwXzcC8ixEdDk8l6W0kYE7TmFZjZkBG9dUftO3Xd7S5bIlq2nDIuQgA98eKtgVOSOY+6j2ZEdDH1Zz7zkNSDx6tbnslH31uDkVeT888MSlg6mPDWKr6ZujyjVCh5y9z2qXLU5lUYamtZoXwFOkgsxdmN/QOwkRTt+WM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705809421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DvV5SPTnS6O+nh2PfHe5PaDc1YhFAjA6pmeic4HMeC4=; b=eQsXhklbeNPLdtKXajs+N/bQ/vsVqmCIGE5uJ3QdgzE0zQlnRJoFCm7MKcLURvj8JkKFBv W/WHaLOFfX1U+IHqacesqylI97894jU44wovAYN8iLRbheMFHyylzYeDdHLgKZH3H5Uuw/ 6r1FVYPsHpVbFps50zQIAEL9hOnA6WA= Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-PXLEcR2OM4GHlBViedC0tw-1; Sat, 20 Jan 2024 22:57:00 -0500 X-MC-Unique: PXLEcR2OM4GHlBViedC0tw-1 Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-210ceab8e18so1350487fac.0 for ; Sat, 20 Jan 2024 19:57:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705809419; x=1706414219; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DvV5SPTnS6O+nh2PfHe5PaDc1YhFAjA6pmeic4HMeC4=; b=hzfCkF0yBbyDFpVztD3DhppHb9a7PEJLN4i8W/6iRriYYBybz0sGjDnR2+VvcecpQS dC9HLItEyg9k0uKaNfXphhG/Z8LyEX2KwWe1kLtC6rVOe+zj0UT5XPTBpDFjQyF8xxso 6uW18tKidWHTF3vuPA2lOmfnghnx0ESQKx0kS831GFcY+Vfm9dmNnV6VtwnyLJeLKWDr 4OKJKBUTAbiZ6HBodvVb9IXvkEfCzA2kaRk22jyIs2g+5rZzH6j9s06FOEJvn/tgejlh 4SAUktcsW45M6sYArp86tHsbRZtxewa1kBbKg8FM65qUL3LafflxbhWUttJ47z+9Htow TYZA== X-Gm-Message-State: AOJu0Yyg5GyR85Gs/L9Dok10a0GSIzgmz3qgAjt15I3z3pEIoDmc6Z+P hC0jTt/V7WbLPf9sGBBD5HTPJ8EOG5DOY++np4N0msaAIAVXm4yAvcBfGcGhTK2BDk1yDd9rEO6 wFu3svtM00LAv+rhghmFml2s0bQ3bfZFeLx2adoXCH42aucQAAj1CQef4j6rnMQnOogE= X-Received: by 2002:a05:6808:2195:b0:3bd:4dd5:7d5 with SMTP id be21-20020a056808219500b003bd4dd507d5mr2187862oib.107.1705809419220; Sat, 20 Jan 2024 19:56:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFtB/k1qS1xsK7WiWqvMNkLdfXsS/rXcE1wboJ3Aq4gTK5DeAcIM8KUcf83A3xgh6VP8HlJQ== X-Received: by 2002:a05:6808:2195:b0:3bd:4dd5:7d5 with SMTP id be21-20020a056808219500b003bd4dd507d5mr2187857oib.107.1705809418963; Sat, 20 Jan 2024 19:56:58 -0800 (PST) Received: from [150.1.200.12] (174-21-92-140.tukw.qwest.net. [174.21.92.140]) by smtp.gmail.com with ESMTPSA id db11-20020a17090ad64b00b002900eeada1asm6834134pjb.43.2024.01.20.19.56.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Jan 2024 19:56:58 -0800 (PST) Message-ID: <90e7d4f6-ed31-421c-a896-750fe6e382a3@redhat.com> Date: Sat, 20 Jan 2024 19:56:58 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 04/16] gdb: remove the !startup_with_shell path from construct_inferior_arguments To: Andrew Burgess , gdb-patches@sourceware.org References: From: Keith Seitz In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 1/9/24 06:26, Andrew Burgess wrote: > diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc > index 55149ec1f13..076ddc73d51 100644 > --- a/gdbsupport/common-inferior.cc > +++ b/gdbsupport/common-inferior.cc > @@ -32,92 +32,66 @@ construct_inferior_arguments (gdb::array_view argv) > { > std::string result; > > - if (startup_with_shell) > - { > #ifdef __MINGW32__ > - /* This holds all the characters considered special to the > - Windows shells. */ > - static const char special[] = "\"!&*|[]{}<>?`~^=;, \t\n"; > - static const char quote = '"'; > + /* This holds all the characters considered special to the > + Windows shells. */ > + static const char special[] = "\"!&*|[]{}<>?`~^=;, \t\n"; > + static const char quote = '"'; > #else > - /* This holds all the characters considered special to the > - typical Unix shells. We include `^' because the SunOS > - /bin/sh treats it as a synonym for `|'. */ > - static const char special[] = "\"!#$&*()\\|[]{}<>?'`~^; \t\n"; > - static const char quote = '\''; > + /* This holds all the characters considered special to the > + typical Unix shells. We include `^' because the SunOS > + /bin/sh treats it as a synonym for `|'. */ > + static const char special[] = "\"!#$&*()\\|[]{}<>?'`~^; \t\n"; > + static const char quote = '\''; > #endif > - for (int i = 0; i < argv.size (); ++i) > + for (int i = 0; i < argv.size (); ++i) > + { > + if (i > 0) > + result += ' '; > + > + /* Need to handle empty arguments specially. */ > + if (argv[i][0] == '\0') > { > - if (i > 0) > - result += ' '; > + result += quote; > + result += quote; > + } > + else > + { > +#ifdef __MINGW32__ > + bool quoted = false; > > - /* Need to handle empty arguments specially. */ > - if (argv[i][0] == '\0') > + if (strpbrk (argv[i], special)) > { > - result += quote; > + quoted = true; > result += quote; > } > - else > +#endif > + for (char *cp = argv[i]; *cp; ++cp) Re: "*cp": Didn't we move to explicit checks some time ago? Keith > { > -#ifdef __MINGW32__ > - bool quoted = false; > - > - if (strpbrk (argv[i], special)) > + if (*cp == '\n') > { > - quoted = true; > + /* A newline cannot be quoted with a backslash (it > + just disappears), only by putting it inside > + quotes. */ > + result += quote; > + result += '\n'; > result += quote; > } > -#endif > - for (char *cp = argv[i]; *cp; ++cp) > + else > { > - if (*cp == '\n') > - { > - /* A newline cannot be quoted with a backslash (it > - just disappears), only by putting it inside > - quotes. */ > - result += quote; > - result += '\n'; > - result += quote; > - } > - else > - { > #ifdef __MINGW32__ > - if (*cp == quote) > + if (*cp == quote) > #else > - if (strchr (special, *cp) != NULL) > + if (strchr (special, *cp) != NULL) > #endif > - result += '\\'; > - result += *cp; > - } > + result += '\\'; > + result += *cp; > } > + } > #ifdef __MINGW32__ > - if (quoted) > - result += quote; > + if (quoted) > + result += quote; > #endif > - } > - } > - } > - else > - { > - /* In this case we can't handle arguments that contain spaces, > - tabs, or newlines -- see breakup_args(). */ > - for (char *arg : argv) > - { > - char *cp = strchr (arg, ' '); > - if (cp == NULL) > - cp = strchr (arg, '\t'); > - if (cp == NULL) > - cp = strchr (arg, '\n'); > - if (cp != NULL) > - error (_("can't handle command-line " > - "argument containing whitespace")); > - } > - > - for (int i = 0; i < argv.size (); ++i) > - { > - if (i > 0) > - result += " "; > - result += argv[i]; > } > } >