From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id F2A561F953 for ; Mon, 13 Dec 2021 06:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232340AbhLMGcZ (ORCPT ); Mon, 13 Dec 2021 01:32:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbhLMGcQ (ORCPT ); Mon, 13 Dec 2021 01:32:16 -0500 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C314EC061D60 for ; Sun, 12 Dec 2021 22:32:09 -0800 (PST) Received: by mail-io1-xd30.google.com with SMTP id q72so17300028iod.12 for ; Sun, 12 Dec 2021 22:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mmhBWxqwjpgfEcyMowsTQ3vctc/dSWgSEKmTOODaLMQ=; b=jqWC7ndI8zCB3gOm0ODFwzapPU/nqDq7JFKisEqPUwvkv18GeBeva+V6GwdVzBMaUB f41fTgmcLFvCg+YXKoY7GhB0s0mJR7CDVMVUG4BcoKHrCxpz2TTpfCZ/oHW4yGNx1lQm 78/4FA2+fxAc2Q3CiyAz4AERp6+lP7X+HVC2CJ3r75sfFuGObbNFBCoN3jXN9YQqo1oJ rGBAzk2j0OvovPL02VU6SGPH4AC7TXO73na/DL9sw1aTI/0p/37RIalnSMP/o3qjhKmF Xo8wlhA1NmSMsMwn9wVIqhZvS9nIpFxipAqhEOb6uY1jc6Q3cvECAUGcb3NgEbf3vGuE 19JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=mmhBWxqwjpgfEcyMowsTQ3vctc/dSWgSEKmTOODaLMQ=; b=kCpZwme2/XS6fygmcOsNwpdw9PzHQ24CHbcL31kYUTc+fp4M+NBF5faMGoiqEEku4k vjuora5GlTAJA52xPILLtkwLfL+r3RhCaUAyOeeyQHIKJdpU49kh34dugeD59+QCgVqn 72ReEpoOnKTZ34ool2NgTaWEPHTg5GoKO1gzLsQHPQBfGwElEezF87gf8hh62PpzcyYL bk7WQ85pEVONNeglYeMD6eNGB4QfgvAUAYB76XeZPjqBZVzPHaQ+z2/buY2losnHC4vr WKItUDCvwVkfcp5WJazGGshPlFSbpNZg1/cjvdRgyNpa8WaAzaO2GEzFGgQsonBK0wxf l11Q== X-Gm-Message-State: AOAM5334QmzrRSSP6FGup7qg5Tzfwv+pKS9JWm48ZUm7My0qaZAaPI8e sityNKmV10PB9hlJFmq3TgvjBlfb4Xim5Q== X-Google-Smtp-Source: ABdhPJy3Pk/nzZ0WjZYRBtEE5sLf4iA9ZcbInbtFK+IaHGjg3JWqXAJdTpV+MH0qO+SBohNBFay6OQ== X-Received: by 2002:a05:6602:14cd:: with SMTP id b13mr32581103iow.203.1639377128648; Sun, 12 Dec 2021 22:32:08 -0800 (PST) Received: from localhost.localdomain (097-069-216-153.res.spectrum.com. [97.69.216.153]) by smtp.gmail.com with ESMTPSA id f10sm7305408ils.13.2021.12.12.22.32.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Dec 2021 22:32:08 -0800 (PST) Sender: Eric Sunshine From: Eric Sunshine To: git@vger.kernel.org Cc: Jeff King , Elijah Newren , Fabian Stelzer , Eric Sunshine Subject: [PATCH 14/15] chainlint.sed: swallow comments consistently Date: Mon, 13 Dec 2021 01:30:58 -0500 Message-Id: <20211213063059.19424-15-sunshine@sunshineco.com> X-Mailer: git-send-email 2.34.1.397.gfae76fe5da In-Reply-To: <20211213063059.19424-1-sunshine@sunshineco.com> References: <20211213063059.19424-1-sunshine@sunshineco.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When checking for broken a &&-chain, chainlint.sed knows that the final statement in a subshell should not end with `&&`, so it takes care to make a distinction between the final line which is an actual statement and any lines which may be mere comments preceding the closing ')'. As such, it swallows comment lines so that they do not interfere with the &&-chain check. However, since `sed` does not provide any sort of real recursion, chainlint.sed only checks &&-chains in subshells one level deep; it doesn't do any checking in deeper subshells or in `{...}` blocks within subshells. Furthermore, on account of potential implementation complexity, it doesn't check &&-chains within `case` arms. Due to an oversight, it also doesn't swallow comments inside deep subshells, `{...}` blocks, or `case` statements, which makes its output inconsistent (swallowing comments in some cases but not others). Unfortunately, this inconsistency seeps into the chainlint self-test "expect" files, which potentially makes it difficult to reuse the self-tests should a more capable chainlint ever be developed. Therefore, teach chainlint.sed to consistently swallow comments in all cases. Signed-off-by: Eric Sunshine --- t/chainlint.sed | 21 +++++++++++++++++++-- t/chainlint/block-comment.expect | 6 ++++++ t/chainlint/block-comment.test | 8 ++++++++ t/chainlint/case-comment.expect | 8 ++++++++ t/chainlint/case-comment.test | 11 +++++++++++ t/chainlint/nested-subshell-comment.expect | 2 -- 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 t/chainlint/block-comment.expect create mode 100644 t/chainlint/block-comment.test create mode 100644 t/chainlint/case-comment.expect create mode 100644 t/chainlint/case-comment.test diff --git a/t/chainlint.sed b/t/chainlint.sed index 0e575c0c62..b1505ef2cd 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -294,6 +294,12 @@ bfolded x s/?!HERE?!/<