You are not logged in.
I'm scratching my brain on this little project my friend roped me into.
I have a function which generates a list of VM's and their states and stores it as a variable. this list is to be presented to the user using the libgui.sh 'ask_option' function. The problem is that the ask_option function does not interpret it correctly. And by saying ask_option isn't doing it right I mean I am expecting a certain behavior, and that expectation is flawed.
Here are the two parts in question
#assume VMLIST has a value identical to this assignment after my function call:
#I have confirmed that this is the exact value
VMLIST="\"Arch Linux Live\" \"running\" \"Windows XP\" \"power off\""
ask_option 0 "VMs Present" '' optional "0" "Return to the Main Menu" $VMLIST
What I actually get shows that ask_option is interpreting each discreet word as an argument. whereas I want the argument to be the text between each quote
0 Return to Main Menu
"Arch Linux
Live" "running"
"Windows XP"
"power off"
Obviously what I want is a two column output in the dialog that resembles
0 Return to Main Menu
Arch Linux Live running
Windows XP power off
What should our approach be to rectify this? How can I use the variable to suppply discreet arguments to another function? or rather how can I have the value of the variable interpreted literally on the function call line?
Last edited by OrionFyre (2011-04-05 19:04:49)
Offline
$ dumpargs() { for i in "$@" ; do echo $i ; done ; }
$ dumpargs $VMLIST
"Arch Linux Live" "running" "Windows XP" "power off"
$ eval dumpargs $VMLIST
Arch Linux Live
running
Windows XP
power off
Offline
ok... I get the logic.
But it's still behaving exactly the same...
ask_option 0 "VMs Present" '' required "0" "Return to Main Menu" `dumpargs $VMLIST`
Am I doing something completely wrong?
Offline
ARRAYS! I knew that
Thanks scary face kitteh!
I should have remembered arrays. alas. that's what happens when you don't use it for a while.
Offline