From patchwork Mon Dec 13 06:30:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 12673129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1C51C433EF for ; Mon, 13 Dec 2021 06:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbhLMGcW (ORCPT ); Mon, 13 Dec 2021 01:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232290AbhLMGcP (ORCPT ); Mon, 13 Dec 2021 01:32:15 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0EE8C061201 for ; Sun, 12 Dec 2021 22:32:08 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id v13so789342ilm.8 for ; Sun, 12 Dec 2021 22:32:08 -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=7bsOSnyGX0H/4cgERmdUVUrE6yzLyDfJPjeeswTetlo=; b=cYm3yhCHTAZ+Tg0UkZl0adfYBViqxNtsWov9xWwD/9DIPDTt+HsCeIrPPHX0ZUp2vI hyAJIDDaso7OIrkGHbEQwGSzE2VbM0W9gbRZdw1oZWEEn4duW7xBpabiGs0Ud2kvzvbk hVD18gSQ3fdc0m09uCQTqZU9FyB2jbA5IKJ4YoVlrdOt7Fap3wH7jKL9HsDFmOwNMqlx efrUekQLfdPXU2shswvEFnPsHos2OvpKDr2hGfeu5Yq7x8WOiEWCApAA1OfbwnFeVhfK Vr0Mb25hDIZiMmQ2ElRUQgZg/2jVXGruEzxUnbxeOGOpHIR2qsKZ69j70lSXBQ1O25GT k0Aw== 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=7bsOSnyGX0H/4cgERmdUVUrE6yzLyDfJPjeeswTetlo=; b=najR7E+c3q7K2vkfCZI7drovzlP1LBnQ7sdzkLxFgovf3ztSX0wDhDelG1d8F1miOZ SJaVYbPHgzurRPN83rnAwO+HaC0XUdxDS+K8GWAeFfJQIYy290ku9w/Tv4Q6tPrehHCq dzQ31PU9WU1WQGQkN9nLg/Hou1B1XDSnkErkh/tRjiyuWKw9Kwyh7w4Xf0WIB/aRmTfg g4AlThGDtaxQ3l9h7RR9kfMNun0yNQuYnEUjr94rpjWJvWwBHPk39pIIUWpWbkgeWRYa iZyCAObVsxX5VzE47qJ2Ue9Dv/cdVbohKhWm8ap+hFpy3P1+0dT1lkoxdVfateMpopX3 6Cwg== X-Gm-Message-State: AOAM53148tn068Wb4F1VI2e7wSj9KNg/amRrKNSxbjPrrB+1ClkwYw8R F7OYY+PPpP0cbwi5C/8rgdI0Rq70vlPXdA== X-Google-Smtp-Source: ABdhPJzREDr1lzrBtavlKnq5ziQ/8PP8j6TVPKowzC9+zfm1XfPF/ivMX+Tqy5SQxZH4iPqHFl2cuw== X-Received: by 2002:a05:6e02:16cd:: with SMTP id 13mr3812371ilx.136.1639377127845; Sun, 12 Dec 2021 22:32:07 -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:07 -0800 (PST) Sender: Eric Sunshine From: Eric Sunshine To: git@vger.kernel.org Cc: Jeff King , Elijah Newren , Fabian Stelzer , Eric Sunshine Subject: [PATCH 13/15] chainlint.sed: stop throwing away here-doc tags Date: Mon, 13 Dec 2021 01:30:57 -0500 Message-Id: <20211213063059.19424-14-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 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The purpose of chainlint is to highlight problems it finds in test code by inserting annotations at the location of each problem. Arbitrarily eliding bits of the code it is checking is not helpful, yet this is exactly what chainlint.sed does by cavalierly and unnecessarily dropping the here-doc operator and tag; i.e. `cat < --- t/chainlint.sed | 24 ++++++++++++------- t/chainlint/for-loop.expect | 2 +- t/chainlint/here-doc-close-subshell.expect | 2 +- .../here-doc-multi-line-command-subst.expect | 2 +- t/chainlint/here-doc-multi-line-string.expect | 2 +- t/chainlint/here-doc.expect | 8 +++---- t/chainlint/if-then-else.expect | 2 +- t/chainlint/nested-here-doc.expect | 6 ++--- t/chainlint/subshell-here-doc.expect | 10 ++++---- t/chainlint/t7900-subtree.expect | 4 ++-- t/chainlint/while-loop.expect | 2 +- 11 files changed, 35 insertions(+), 29 deletions(-) diff --git a/t/chainlint.sed b/t/chainlint.sed index 2f786f890d..0e575c0c62 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -62,20 +62,20 @@ # receives similar treatment. # # Swallowing here-docs with arbitrary tags requires a bit of finesse. When a -# line such as "cat <out" is seen, the here-doc tag is moved to the front -# of the line enclosed in angle brackets as a sentinel, giving "cat >out". +# line such as "cat <cat <\n\1$/ is attempted to see if # the content inside "<...>" matches the entirety of the newly-read line. For # instance, if the next line read is "some data", when concatenated with the -# target line, it becomes "cat >out\nsome data", and a match is attempted +# target line, it becomes "cat <cat >out\nEOF", +# encountered, it is appended to the target line giving "cat <" does match the text following the # newline, thus the closing here-doc tag has been found. The closing tag line # and the "<...>" prefix on the target line are then discarded, leaving just -# the target line "cat >out". +# the target line "cat <\1<\1\2/ :hered N /^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{ @@ -238,6 +237,7 @@ s/.*\n// :cont # retrieve and print previous line x +s/?!HERE?!/<\1<\1?!HERE?!\2\3/ :hdocsub N /^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{ @@ -293,6 +292,7 @@ bfolded # found "case ... in" -- pass through untouched :case x +s/?!HERE?!/<foo && +cat <<-Arbitrary_Tag_42 >foo && -cat >boo && +cat <boo && -horticulture +horticulture <foop && +cat <foop && ( - cat && - cat ?!AMP?! + cat <<-INPUT_END && + cat <<-EOT ?!AMP?! foobar ) diff --git a/t/chainlint/subshell-here-doc.expect b/t/chainlint/subshell-here-doc.expect index b7250ca753..029d129299 100644 --- a/t/chainlint/subshell-here-doc.expect +++ b/t/chainlint/subshell-here-doc.expect @@ -1,10 +1,10 @@ ( - echo wobba gorgo snoot wafta snurb && - cat >bip ?!AMP?! - echo >bop + echo wobba gorgo snoot wafta snurb <<-EOF && + cat <bip ?!AMP?! + echo <<-EOF >bop ) && ( - cat >bup && - cat >bup3 && + cat <<-ARBITRARY >bup && + cat <<-ARBITRARY3 >bup3 && meep ) diff --git a/t/chainlint/t7900-subtree.expect b/t/chainlint/t7900-subtree.expect index 215aca01c2..1cccc7bf7e 100644 --- a/t/chainlint/t7900-subtree.expect +++ b/t/chainlint/t7900-subtree.expect @@ -1,9 +1,9 @@ ( chks="sub1sub2sub3sub4" && - chks_sub=$(cat | sed "s,^,sub dir/," + chks_sub=$(cat <