From: tboegi@web.de
To: git@vger.kernel.org, Johannes.Schindelin@gmx.de
Cc: "Torsten Bögershausen" <tboegi@web.de>
Subject: [PATCH v3 1/1] check-non-portable-shell.pl: Quoted `wc -l` is not portable
Date: Thu, 21 Dec 2017 22:26:46 +0100 [thread overview]
Message-ID: <20171221212646.24461-1-tboegi@web.de> (raw)
In-Reply-To: <xmqqh8t2ckgw.fsf@gitster.mtv.corp.google.com>
From: Torsten Bögershausen <tboegi@web.de>
wc -l was used to count the number if lines in test scripts.
$ wc -l Makefile
gives a line like this:
105 Makefile
while Mac OS has 4 leading spaces:
105 Makefile
And this means that shell expressions like
test "$(wc -l <expect)" = "4" don't work under Mac OS,
Commit fb3340a6 introduced test_line_count() as a portable solution.
Add a check in check-non-portable-shell.pl to find '"' between
`wc -l` and '=' and hint the user about test_line_count().
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
t/check-non-portable-shell.pl | 1 +
1 file changed, 1 insertion(+)
diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl
index 03dc9d285..e07f02843 100755
Use () around the hint.
Thanks to Eric for the sharp eyes.
--- a/t/check-non-portable-shell.pl
+++ b/t/check-non-portable-shell.pl
@@ -21,6 +21,7 @@ while (<>) {
/^\s*declare\s+/ and err 'arrays/declare not portable';
/^\s*[^#]\s*which\s/ and err 'which is not portable (please use type)';
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (please use =)';
+ /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (please use test_line_count)';
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (please use FOO=bar && export FOO)';
# this resets our $. for each file
close ARGV if eof;
--
2.15.1.271.g1a4e40aa5d
next prev parent reply other threads:[~2017-12-21 21:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 21:46 What's cooking in git.git (Dec 2017, #01; Mon, 4) Junio C Hamano
2017-12-04 22:04 ` Jeff Hostetler
2017-12-04 22:26 ` Elijah Newren
2017-12-04 23:46 ` Jonathan Tan
2017-12-05 0:30 ` Junio C Hamano
2017-12-06 15:14 ` Lars Schneider
2017-12-06 16:03 ` Torsten Bögershausen
2017-12-06 16:48 ` Junio C Hamano
2017-12-07 15:48 ` Johannes Schindelin
2017-12-07 20:22 ` Todd Zullinger
2017-12-07 20:50 ` Junio C Hamano
2017-12-07 21:08 ` Lars Schneider
2017-12-07 21:21 ` Junio C Hamano
2017-12-07 21:08 ` Jeff Hostetler
2017-12-07 21:10 ` Junio C Hamano
2017-12-10 10:50 ` [PATCH v1 1/1] check-non-portable-shell.pl: Quoted `wc -l` is not portable tboegi
2017-12-10 13:59 ` Johannes Schindelin
2017-12-11 23:07 ` Junio C Hamano
2017-12-16 19:52 ` [PATCH v2 " tboegi
2017-12-17 0:06 ` Eric Sunshine
2017-12-21 21:26 ` tboegi [this message]
2017-12-22 21:07 ` [PATCH v3 " Junio C Hamano
2017-12-23 7:27 ` Torsten Bögershausen
2017-12-07 21:33 ` What's cooking in git.git (Dec 2017, #01; Mon, 4) Todd Zullinger
2017-12-09 14:46 ` Torsten Bögershausen
2017-12-10 13:50 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171221212646.24461-1-tboegi@web.de \
--to=tboegi@web.de \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).