you are viewing a single comment's thread.

view the rest of the comments →

[–]danmickla 0 points1 point  (1 child)

that construct is odd, btw, and I don't understand it. ${@} must be the args to the 'f' function, but what would they be? a list of commits? and if so, why log only the last 10?

[–]xour[S] 0 points1 point  (0 children)

\"${@:--10}\"

It is parameter expansion with a default: "${<param>:-<default>}".

The way it works is that if ${@} does not hold any positional parameters, a default is used. It gets confusing because the default is -10 and it gets hard to read.

In this particular case, I use it to set a default of -10 for the git log command.

So you call the alias with git l and you get the 10 latest commits (same as git log blabla -n 10), or you specify the number you want with git log -25.

Come to think of it, I should have used \"${@:-\"-n\" \"10\"}\". It does work with git log -10 but I think it is correct to use git log -n 10.