gtkdialog again, the other way around this time – how to use bash variables in dialog?
Johnny Rosenberg
gurus.knugum at gmail.com
Sat Apr 20 23:20:05 UTC 2013
Here is some nonsense code that I'm trying to make work:
#!/bin/bash
#--- Define some variables -----------------------------------------------------
RosenTagDir="${HOME}/bin/RosenTagg"
InstrumentsList="${RosenTagDir}/Lists/Instruments"
MusiciansList="${RosenTagDir}/Lists/Musicians"
#-------------------------------------------------------------------------------
#--- Define and open the dialogue ----------------------------------------------
export MainDialog='
<vbox>
<hbox>
<text>
<label>Instrument:</label>
</text>
<comboboxentry>
<default>Välj musikinstrument</default>
<variable>Instrument</variable>
<input file>$InstrumentsList</input>
</comboboxentry>
<text>
<label>Utövare:</label>
</text>
<comboboxentry>
<default>Välj utövare</default>
<variable>Musician</variable>
<input file>$MusiciansList</input>
</comboboxentry>
</hbox>
<hbox>
<button ok></button>
<button cancel></button>
</hbox>
</vbox>'
gtkdialog --program MainDialog
#-------------------------------------------------------------------------------
The problem is that $InstrumentsList and $MusiciansList doesn't
expand, and whatever I tried I failed.
MainDialog is just a variable, right? But how do I make bash variables expand?
I have tried to fiddle with eval with no luck, for instance:
$ echo $MainDialog
<vbox> <hbox> <text> <label>Instrument:</label> </text>
<comboboxentry> <default>Välj musikinstrument</default>
<variable>Instrument</variable> <input file>$InstrumentsList</input>
</comboboxentry> <text> <label>Utövare:</label> </text>
<comboboxentry> <default>Välj utövare</default>
<variable>Musician</variable> <input file>$MusiciansList</input>
</comboboxentry> </hbox> <hbox> <button ok></button> <button
cancel></button> </hbox> </vbox>
$ eval echo $MainDialog
bash: syntaxfel nära den oväntade symbolen "<"
$
(The error message, which is in Swedish, means something like ”syntax
error near the unexpected symbol ”<”.)
So obviously (?) I need a way to expand the variables but nothing
else. Unfortunately I am a bit out of ideas, which is maybe not so
strange considering that I'm not only a gtkdialog beginner; I'm a bash
beginner as well, even though I learned a lot last years…
Johnny Rosenberg
More information about the ubuntu-users
mailing list