We can define git alias
to run shell commands like this:
[alias]
echo = !echo
echo2 = !echo "$1" && echo "====" && echo "${@:2}" && :
(The last && :
is used because the command line arguments are appended to the command again by git, and :
turns them into no-op
.)
Now my question is how does git run these commands.
Does it spawn a shell (like sh
) to run it?
I tried the above alias in two computers, one ubuntu
and one centos
. In ubuntu
, the echo2
fails to expand the parameter ${@:2}
, which in bash
is expanded to the args starting from the second to the end of the list.
I guess that in ubuntu
sh
is used but sh
is a link to dash
. Unfortunately dash
doesnot know ${@:2}
. In centos
sh
is linked to bash
and it works.
Can we have a way to choose the shell used in running these alias?