On Tue, Mar 22, 2011 at 11:38:06AM +0100, Lasse Makholm wrote: > > The attached quick hack gives > > > > Â$ git config alias.silly > > Â!echo hello $1; echo $# args, bye! > > Â$ GIT_TRACE=1 ./git silly world funny > > Âtrace: exec: 'git-silly' 'world' 'funny' > > Âtrace: run_command: 'git-silly' 'world' 'funny' > > Âtrace: run_command: 'sh' '-c' 'echo hello $1; echo $# args, bye'\!'' '-' 'world' 'funny' > > Âtrace: exec: 'sh' '-c' 'echo hello $1; echo $# args, bye'\!'' > > Â'-' 'world' 'funny' > > Âhello world > > Â2 args, bye! > > That would IMHO be The Right Way to do it. Since the documentation for > aliases promises to to pass my alias to a shell if I prefix it with > "!", I shouldn't have to add the "sh -c ... -" myself... It does pass it to the shell. You can do: $ git config alias.autolog --oneline !repo=`find-git-repo-for $PWD` && git --git-dir="$repo" log for an example of a shell-based alias. It just doesn't handle positional parameters the way you want. The typical solution is to invoke another shell, but you can also do: $ grep -B1 silly .git/config [alias] silly = "!foo() { echo hello $1; echo $# args, bye!\n}\nfoo" which unsurprisingly looks like exactly the same solution one would use in the shell to avoid the fact that shell aliases suck for handling positional parameters. > > but it would penalize a properly written alias that uses "sh -c <it> -" > > trick itself by double forking, which is not very nice and I am unhappy > > about. > > A properly written alias that uses a trick? I guess that sums up the > problem... :-) Yeah. Though it also penalizes non-tricky aliases. See my other mail in this thread. > Anyway, doesn't the existing way potentially break when passing funky > arguments containing spaces/quotes/something? We currently pass the > arguments to the alias command as a single quoted string. Passing them > as seperate elements on argv seems a lot more robust... No, the arguments in the current scheme are properly shell-quoted before they are appended to the shell snippet. So they are equally robust. -Peff -- 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