From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Jay Soffian <jaysoffian@gmail.com>, Jeff King <peff@peff.net>,
Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH 3/3] help: respect aliases
Date: Tue, 26 Feb 2008 12:14:49 -0800 [thread overview]
Message-ID: <7vve4b4gqu.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LSU.1.00.0802261222570.17164@racer.site> (Johannes Schindelin's message of "Tue, 26 Feb 2008 12:43:21 +0000 (GMT)")
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Hi,
>
> On Sun, 24 Feb 2008, Jay Soffian wrote:
>
>> This too would be less ugly as a built-in:
>>
>> alias = "! sh -c 'if test -z \"$1\"; then git config --list \
>> | expand \
>> | sed \"/^alias\\./!d; s/^alias\\.//; s/=/ /; s/ */ /g\" \
>> | sort | while read n v; do \
>> printf \"%-16s\" \"$n\"; echo \"$v\" | gnused \
>> \"s/\\(.\\{68\\}\\) /\\1\\n\t\t/g\" | expand; \
>> done; else git config \"alias.$1\"; fi' -"
>
> Wow. This would look less ugly as an alias like this, too:
>
> alias = "!sh -c 'case $# in \
> 0) git config --get-regexp \"^alias\\.\" | sed \"s/^alias\\.//\";; \
> *) git config \"alias.$0\" ;; \
> esac'"
>
> which incidentally fixes a bug in your alias: you ignore $0 which is the
> first parameter when using the sh -c '' idiom.
I notice that he is feeding an exra '-' for that.
> Of course, you can change the sed call to your liking...
Sure. The combination of expand, sed, and gnused hurts my eyes
;-)
One good lesson to take home is that by ending your lines with
'|', you can tell the shell that you are not done with the
pipeline you are forming yet. This allows you to lose all these
ugly backslashes, like this:
xyzzy |
frotz |
nitfol
instead of
xyzzy \
| frotz \
| nitfol
next prev parent reply other threads:[~2008-02-26 20:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1203890846.git.peff@peff.net>
2008-02-24 22:16 ` [PATCH 1/3] help: use parseopt Jeff King
2008-02-25 6:50 ` Christian Couder
2008-02-25 6:57 ` Jeff King
2008-02-25 7:16 ` Junio C Hamano
2008-02-24 22:17 ` [PATCH 2/3] make alias lookup a public, procedural function Jeff King
2008-02-24 22:17 ` [PATCH 3/3] help: respect aliases Jeff King
2008-02-25 2:10 ` Jay Soffian
2008-02-26 12:43 ` Johannes Schindelin
2008-02-26 14:56 ` Jay Soffian
2008-02-26 15:15 ` Johannes Schindelin
2008-02-26 20:14 ` Junio C Hamano [this message]
2008-02-26 20:31 ` Jay Soffian
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=7vve4b4gqu.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=jaysoffian@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/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).