I want to have command that would execute command in arguments in dir1 and dir2
tests
# put this in our .bashrc
alias gca="git commit -v -a"
my-exec gca
my-exec gca -m "my commit wrapped in double quotes"
my-exec gca -m "my commit wrapped in double quotes with 'something' in single quotes"
my-exec gca -m 'my commit wrapped in single quotes with "something" in double quotes'
I have tried
my-exec () {
(cd $HOME/dir1 && eval "$@")
(cd $HOME/dir2 && eval "$@")
}
but it's not working, because
# working fine
my-exec gca
# executes
# gca -m my commit wrapped in double quotes
# actually
my-exec gca -m "my commit wrapped in double quotes"
# didnt try
my-exec gca -m "my commit wrapped in double quotes with 'something' in single quotes"
# didnt try
my-exec gca -m 'my commit wrapped in single quotes with "something" in double quotes'
UPDATE
also tried
my-exec () {
echo "$@" > /tmp/my-exec
cat /tmp/my-exec
(cd $HOME/dir1 && bash -i /tmp/my-exec)
(cd $HOME/dir2 && bash -i /tmp/my-exec)
}
but echo "$@" too doesn't preserve quotes
eval.eval $@instead oneval "$@"?eval $@is working the same aseval "$@", and thus not applicable to my use caseevalis not executing aliases and thus not applicable to my use casegca () { git commit -v -a "$@"; }. That should at least allowcd ... && "$@"to work inmy_exec.