BASH: Running zenity from variables


pmprog

DNF (Did Not Finish)
Joined
Apr 25, 2011
Messages
4,150
So I started witing a script to parse the upgrade log to display config file changes, but I'm getting some unexpected behaviour

#!/bin/bash

zcmd="zenity --list --checklist --column=\"\" --column=\"Config File\" --column=\"Temp Location\" "

while read line
do
if [[ $line = *Download* ]]
then
zcmd="$zcmd x $(echo $line | cut -f2 -d" ")"
fi
done </tmp/upgrade.log

echo "$zcmd"
$zcmd
When I run this, my dialogue is messed up, with Config File column header showing "Config (with the quotes). However if I copy and run the echo'd variable contents it works okay.

Example of my output

Code:
zenity --list --checklist --column="" --column="Config File" --column="Temp Location"  x http://openpandora.org/feeds/unstable/all/Packages.gz. x http://openpandora.org/feeds/unstable/armv7a/Packages.gz. x http://openpandora.org/feeds/unstable/omap3-pandora/Packages.gz.
Any ideas? Cheers
 
Quoting and avoiding unwanted argument separation can be hell.

Maybe in this case it suffices to use single quotes instead of escaped double quotes:

Code:
zcmd="zenity --list --checklist --column='' --column='Config File' --column='Temp Location' "
 
Thanks. Just tried that, and it doesn't work. It show shows the single quotes in the zenity list
 
Fixed that for you ;)
Ahh, that's what I was looking for. For some reason I thought it was "exec" or "execute", and neither of them worked, so I tried backticks.

But yeah, sorted. Thanks.
 
Back
Top