From: tboegi@web.de
To: git@vger.kernel.org
Cc: "Torsten Bögershausen" <tboegi@web.de>
Subject: [PATCH v1 1/1] check-non-portable-shell.pl: Quoted `wc -l` is not portable
Date: Sun, 10 Dec 2017 11:50:13 +0100 [thread overview]
Message-ID: <20171210105013.3984-1-tboegi@web.de> (raw)
In-Reply-To: <xmqqh8t2ckgw.fsf@gitster.mtv.corp.google.com>
From: Torsten Bögershausen <tboegi@web.de>
wc -l is 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,
A portable way to use `wc -l` is to omit the '"':
test $(wc -l <expect) = "4"
Add a check in check-non-portable-shell.pl to find '"' between
`wc -l` and '='
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 03dc9d2852..9ebf65c26f 100755
--- 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 `$(wc -l)`';
/\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-10 10:50 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 ` tboegi [this message]
2017-12-10 13:59 ` [PATCH v1 1/1] check-non-portable-shell.pl: Quoted `wc -l` is not portable 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 ` [PATCH v3 " tboegi
2017-12-22 21:07 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171210105013.3984-1-tboegi@web.de \
--to=tboegi@web.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.