Re: [PATCH 3/3] help: respect aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> 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



-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux