From: Michael J Gruber <git@drmicha.warpmail.net>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Stephen Boyd" <bebarino@gmail.com>,
"Andreas Ericsson" <ae@op5.se>,
"Sverre Rabbelier" <srabbelier@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Jakub Narebski" <jnareb@gmail.com>
Subject: Re: [PATCHv2] Makefile: implement help target
Date: Wed, 29 Sep 2010 09:03:35 +0200 [thread overview]
Message-ID: <4CA2E4C7.305@drmicha.warpmail.net> (raw)
In-Reply-To: <20100929051640.GA26324@sigill.intra.peff.net>
Jeff King venit, vidit, dixit 29.09.2010 07:16:
> On Tue, Sep 28, 2010 at 10:38:04PM +0200, Michael J Gruber wrote:
>
>> +help:
>> + @awk '/^# Help:/ { l=substr($$0,8); \
>> + getline; \
>> + j=index(l,":"); \
>> + print substr(l,1,j-1), substr($$0,1,index($$0,":")), substr(l,j+2); \
>> + }' <Makefile | sort | while read category target text; \
>> + do \
>> + test "$$category" = "$$currcat" || printf "$$category targets:\n"; \
>> + currcat="$$category"; \
>> + printf " %-20s%s\n" "$$target" "$$text"; \
>> + done
>
> Surely this is why we have perl?
I don't speak perl.
Honestly, this is slowly going on my nerves. Maybe it's because I'm
reading too many "can't we do it this way" responses in one go and
without being coffeinated, and without seeing how "different" is better.
[I've been heeding all advise on portability and readability, as you can
see.]
So far we've been using neither awk nor perl in the Makefile, but sed.
> help:
> @perl -n0777 \
> -e 'push @{$$h{$$1}}, [$$3, $$2] while /^# Help: (.*?): (.*)\n(.*?):/mg;' \
On top of everything else, you're even slashing mg! (See, I'm less
grumpy already...)
> -e 'for (sort keys(%h)) {' \
> -e ' print "$$_:\n";' \
> -e ' printf(" %-20s%s\n", @$$_) for (@{$$h{$$_}});' \
> -e '}' Makefile
>
How portable are the regexps and the array/dictionary push?
> Note that mine will actually print the targets in a heading in the order
> in which they appear in the Makefile, which I consider slightly more
> useful (especially in that we can tweak the order easily).
I don't think Makefile order would be useful. If you know exactly what
you're looking for you need no sorting, you can just search for that
term. (I would do a 'grep -A20 "^target:" Makefile' or hit "/^target" in
my vim but I'm sure there's a different way of doing it in perl...)
If you're trying to find your way around you guess a generic term and
look for that, and that's easier to do when the categories are sorted
alphabetically.
Michael
next prev parent reply other threads:[~2010-09-29 7:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-28 8:13 [PATCH] Makefile: Add help target Stephen Boyd
2010-09-28 9:45 ` Junio C Hamano
2010-09-28 11:37 ` Sverre Rabbelier
2010-09-28 12:35 ` Andreas Ericsson
2010-09-28 14:44 ` [PATCH] Makefile: implement " Michael J Gruber
2010-09-28 14:48 ` Sverre Rabbelier
2010-09-28 14:57 ` Zbyszek Szmek
2010-09-28 14:54 ` Ævar Arnfjörð Bjarmason
2010-09-28 15:33 ` Junio C Hamano
2010-09-28 15:47 ` Michael J Gruber
2010-09-28 16:04 ` Ævar Arnfjörð Bjarmason
2010-09-28 20:38 ` [PATCHv2] " Michael J Gruber
2010-09-28 20:51 ` Sverre Rabbelier
2010-09-28 21:24 ` Jakub Narebski
2010-09-28 22:00 ` Brandon Casey
2010-09-29 8:06 ` Michael J Gruber
2010-09-29 5:16 ` Jeff King
2010-09-29 7:03 ` Michael J Gruber [this message]
2010-09-29 7:34 ` Jeff King
2010-09-29 15:41 ` Junio C Hamano
2010-09-29 20:15 ` [PATCHv3] " Michael J Gruber
2010-09-29 20:39 ` Junio C Hamano
2010-09-30 7:08 ` Michael J Gruber
2010-09-29 6:10 ` [PATCH] Makefile: Add " yj2133011
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=4CA2E4C7.305@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=ae@op5.se \
--cc=avarab@gmail.com \
--cc=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=peff@peff.net \
--cc=srabbelier@gmail.com \
/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 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 NNTP newsgroup(s).