Re: Two problems on alias of git

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

 



On Wed, 06 May 2009 00:42:49 +0900, Jakub Narebski <jnareb@xxxxxxxxx> wrote:
> By the way, you can use continuation-of-line character (end line
> with '\') and/or can embed newlines using C escape sequence, i.e. "\n".
>
> So your code can look like this (although I am not sure it is worth it):
>
>   [alias]
>         lr = "!$SHELL -c '                               \n\
>                 n=10;                                    \n\
>                 1=\"${1:-$n}\";                          \n\
>                 if ! [ \"${1##[0-9]*}\" = \"\" ]; then   \n\
>                   t=\"$1\";                              \n\
>                   1=\"${2:-$n}\";                        \n\
>                   2=\"$t\";                              \n\
>                 fi;                                      \n\
>                 git --no-pager l1 --reverse -\"$1\" \"${2:-HEAD}\" \n\
>               ' __dummy__"

Thank you again, I didn't know that.  It is better than what I wrote.


> BTW. you need to quote value because it contains comment character '#'
> in 4th line of script.

Really?  As far as I read the code of git, especially parse_value() in config.c,
it is not necessary to escape '#'s because they are inside of the outermost
doublequotes and they should not be escaped, because \# is an unknown escape
sequence and git rejects them.  If #s are escaped, it causes an error as follows:

$ git config --get alias.lr
fatal: bad config file line 29 in /Users/kana/.gitconfig


-- 
To Vim, or not to Vim.
http://whileimautomaton.net/
--
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]