From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id I3E+M+zKBWBCIwAAWB0awg (envelope-from ) for ; Mon, 18 Jan 2021 12:52:44 -0500 Received: by simark.ca (Postfix, from userid 112) id B9A0C1EF80; Mon, 18 Jan 2021 12:52:44 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 5BBB21E940 for ; Mon, 18 Jan 2021 12:52:44 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FD35388A40D; Mon, 18 Jan 2021 17:52:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FD35388A40D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610992363; bh=D3djyAJUR1jIrmIZRqJ/r/jaRpuXyjZJJSkD72wziWo=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=CBYaEUZWbFEqR5v2/Y5oVzSmq1Wppinmxcjtev1z5dy/bPK6VdA60YqcjH2VxlGmV rRAsBjJAj23QtBYTo+1RbY6zFEcm1Zqe/cwufw0CJRQc0iHBwBo209BTCrlGhAf8H1 nVVN5zAVosMC4qjcdXMsnaruTgC5nKvDoZU25uDU= Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id D91733834438 for ; Mon, 18 Jan 2021 17:52:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D91733834438 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 22224340FF3; Mon, 18 Jan 2021 17:52:40 +0000 (UTC) Date: Mon, 18 Jan 2021 12:52:40 -0500 To: Simon Marchi Subject: Re: [PATCH] sim: common: modernize gennltvals.sh Message-ID: Mail-Followup-To: Simon Marchi , gdb-patches@sourceware.org References: <20210117101044.32143-1-vapier@gentoo.org> <0674d2d0-2534-ac08-c83c-4330d090a1bc@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0674d2d0-2534-ac08-c83c-4330d090a1bc@polymtl.ca> 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: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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 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. * 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