Hi Don,I may not be understanding what you want to achieve, but ignoring the logic, I can get, using the function below without the use of eval or multiple quoting:
$ function show
{ echo $1 _var="$2" OFS="--" _total="$1"$OFS"$2" }
$ show "one two three" four one two three $ echo $_var four $ echo $_total one two three--four Martin----- Original Message ----- From: "Donald Marang" <donald.marang@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Sunday, July 25, 2010 12:31 AM Subject: Need bash script HelpI hope there is someone here with a little experience with functions in a bash script. I wrote a function that will append a filename to a list of filenames. The first argument passed is the name of the variable for a list of filenames. I fashoned this method based on a bash tutorial on how to return values from a function. that use this method and the 'eval' statements within the if statement. Since bash functions can not returna string, passing just the name seems to be a poor man's way to call by reference. The second argument is a filename that will be appended to the lisst.
I think everything is in order except the line below: eval _ResultString="'$1'"I need _ResultString to contain the actual filenames in the variable name in the variable whose name is the first argument. For some reason I can not get this statement correct.
Can anybody know how this assignment statement should look? Here's the function: AddFilenameToString() { # $1 is the variable name of the sttring of filenames # $2 is the new filename to Add local _ResultName="$1" local _ResultString="" eval _ResultString="'$1'" echo "variable name = $_ResultName" echo "value = $_ResultString" if [[ -z "$_ResultString" ]]; then echo "create new string" eval $_ResultName="'$2'" else echo "append to string" eval $_ResultName="'${_ResultString}${IFS}$2'" fi }Don Marang
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind