I'm working on AIX 6, ksh shell. The parameters are some strings quotated by double quotation marks which from a file. They are quotated because there may be spaces in them.
Example:
"015607" "10" " " "A"
I want to pass these parameters to a shell function by writing the following command:
parse $(cat para.txt)
But I didn't get 4 parameters as thought before, instead, there are 5 parameters!
OK, it's hard to say that problem clearly. the script is:
As far as I can guess, when you directly pass parameters to the function using quotes to delimit them, the shell will consider the parameter list without the quotes but with the embedded white-spaces...
But, when you get the argument list from a file using command substitution, the shell will do nothing more about it. It will use the current IFS value to decide the positional parameters.
Though it is a solution to your problem, I don't recall ever putting an eval command in a production script.
There is always a better design like formatting your parameter file such that it is valid Shell syntax and can be executed in the current environment.