My problem is not simple passing parameters with spaces (I know how to achieve that), consider more complicated case:
function build() {
make CC="$1" CFLAGS="$2" $* # $* is not correct here!
}
build gcc "XXX" VAR1="a b" VAR2="c=A d=B" LDFLAGS="-L/opt/lib -lm"
as equivalent to
make CC=gcc CFLAGS=XXX VAR1="a b" VAR2="c=A d=B" LDFLAGS="-L/opt/lib -lm"
I would like to achieve this one to work in shell (portable solutions please, no bashisms, etc). Any suggestions, recommendations?
"$@"which is designed exactly for this purpose?$*and remember"$@"instead."$@"is very often useful whereas"$*"is very rarely useful and the unquoted forms are even rarer.