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 -lmas equivalent tomake CC=gcc CFLAGS=XXX VAR1=a b VAR2=c=A d=B LDFLAGS=-L/opt/lib -lmI would like to achieve this one to work in shell (portable solutions please, no bashisms, etc). Any suggestions, recommendations?
how to properly pass _set_ of parameters with spaces into shell function
shell script;shell;quoting;parameter
There are two elements to a better solution:shift(more) quotingDefine the function using shift, like this:function build {  local cc=$1  local cflags=$2  shift 2  make CC=$cc CFLAGS=$cflags $@}where we save the first two parameters to local variables, then shift the whole argument array by two; also, quote the $@ expansion. Then, call it with extra quoting, like this:build gcc XXX 'VAR1=a b VAR2=c=A d=B' 'LDFLAGS=-L/opt/lib -lm'where the single quotes protect the extra arguments into the function; otherwise, the shell removes the quotes and you'd be left with VAR2=c=A d=B (unquoted) in the function.