This question already has an answer here:
I'm trying to pass multiple argument to a function, but one of them is consist of two words and I want shell function to deal with it as one arg:
args=("$@")
function(){
echo ${args[0]}
echo ${args[1]}
echo ${args[2]}
}
when I call this command sh shell hi hello guys bye
I get this
hi
hello
guys
But what I really want is:
hi
hello guys
bye
function
as a name of a function. It's a keyword inksh
, and some bourne-shell likebash
,zsh
,dash
. – cuonglm Aug 23 '14 at 18:31dash
. Inyash
yes. Thoughzsh
also acceptsksh
's function definition syntax,function() echo x; function
will work inzsh
. So the only shells where that is a problem areksh
,bash
andyash
. – Stéphane Chazelas Aug 23 '14 at 20:05zsh
, butdash
doesn't. – cuonglm Aug 23 '14 at 20:13