From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wemWJsPOBWDMIwAAWB0awg (envelope-from ) for ; Mon, 18 Jan 2021 13:09:07 -0500 Received: by simark.ca (Postfix, from userid 112) id 83EA31EF80; Mon, 18 Jan 2021 13:09:07 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B3D5C1E940 for ; Mon, 18 Jan 2021 13:09:06 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C6013854838; Mon, 18 Jan 2021 18:09:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C6013854838 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610993346; bh=RTbBBz5gICUmRyjxfuwLHwWvzjRvGanWeHKErodW1rU=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=SfO0g9x1MGvpNcf8DUjrsGv5sriPohYQ2CG4draywa9glZsPDrmfhQQEk7w6Z8VFC oRtcWDWZxEc2OI+ufnUJNk2Et0/JQETAcvRzr9Gitd0l4kAUrOYxadwUrMmi93qIXN NA3RXj/oY22fj4shPCBvO6tzciz3k4L8Yx5b5EHk= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 826363854838 for ; Mon, 18 Jan 2021 18:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 826363854838 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10II8wif020709 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Jan 2021 13:09:02 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10II8wif020709 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 1F05B1E940 for ; Mon, 18 Jan 2021 13:08:58 -0500 (EST) Subject: Re: [PATCH] sim: common: modernize gennltvals.sh To: gdb-patches@sourceware.org References: <20210117101044.32143-1-vapier@gentoo.org> <0674d2d0-2534-ac08-c83c-4330d090a1bc@polymtl.ca> Message-ID: <57246960-bd66-6a02-49c2-0d0eb66af777@polymtl.ca> Date: Mon, 18 Jan 2021 13:08:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 18 Jan 2021 18:08:58 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2021-01-18 12:52 p.m., Mike Frysinger wrote: > On 18 Jan 2021 12:19, Simon Marchi via Gdb-patches wrote: >> On 2021-01-18 12:13 p.m., Mike Frysinger wrote: >>> i had run shellcheck and the only warnings (about unquoted expansion) >>> i didn't think we worth fixing because of the limited scope of the >>> script. the variable in question isn't accepting user input, it's >>> operating on fixed inputs, and if we restrict ourselves to POSIX >>> shell (which i think we do), then our options are limited, and imo >>> the alternatives make it harder to read/understand. >> >> Even considering this, I think it's worth just quoting the variables >> and getting rid the warnings. It's trivial, and it would make any >> future (more important) warning more apparent. > > to be clear, it isn't a style issue, it's a correctness issue. > adding the quotes will break the script. > > here's the warning: > printf '#include <%s>\n' ${files} > ^------^ SC2086: Double quote to prevent globbing and word splitting. > > this is because the code passes in multiple files to process as an arg: > gentvals "" errno ... "errno.h sys/errno.h" ... > > then we use it like: > files=$4 > ... > for f in ${files}; do > ... > printf '#include <%s>\n' ${files} > > unquoted, we get: > #include > #include > > quoted, we get: > #include Wait, what. This printf call gives you multiple lines, and does not tell you "you have too many arguments for the format string"? This is... surprising. To produce that output, I would have expected a for loop: for f in ${files}; do printf '#include <%s>\n' "$f" done > > our options are limited with POSIX shell: > * use arrays ... POSIX shell only has one builtin array: the args. > so we'd rework the func API to pass in multiple files, and we'd > operate on $@ by shifting it and iterating. Ok, I'm used to using bash arrays, I forgot they weren't standard. > * change the shell runtime env by disabling path expansion. that > would mitigate the path expansion (which doesn't happen here as > we know the inputs are all alphanumeric/periods), but still would > have word splitting because we want that. > > shell is just a bad programming language. but i think the tree > specifically constrains itself to it for portability. i don't know > what, if any, policies we have about using any other language. > -mike I think it would be perfectly fine to require bash or python. Simon