LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-12-2008, 01:26 PM   #1
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,021

Rep: Reputation: 172Reputation: 172
bash: generating a string containing options and using with kdialog


I'm writing a script where I want to present a list of options in a kdialog radiolist. The options are very similar so I want to generate them in a loop somehow then give them to kdialog. So far I have...
Code:
#!/bin/bash
EMPTY_AFTER_DAYS=1
dialogoptions="";
for i in `seq 1 7`;do
   status="off";
   if [ $i -eq $EMPTY_AFTER_DAYS ];then status="on";fi
   days="days";
   if [ $i -eq 1 ];then days="day";fi
   dialogoptions="$dialogoptions $i 'Automatically remove files from Wastebin after $i $days' $status"
done
echo $dialogoptions
set -x
kdialog --radiolist "Files in the Wastebin count towards your quota usage. Automatically removing files from the Wastebin helps you stay within your quota limit." $dialogoptions
The radio list options are all messed up when they're displayed though. The output I see from using 'set -x' is

Code:
1 'Automatically remove files from Wastebin after 1 day' on 2 'Automatically remove files from Wastebin after 2 days' off 3 'Automatically remove files from Wastebin after 3 days' off 4 'Automatically remove files from Wastebin after 4 days' off 5 'Automatically remove files from Wastebin after 5 days' off 6 'Automatically remove files from Wastebin after 6 days' off 7 'Automatically remove files from Wastebin after 7 days' off
+ kdialog --radiolist 'Files in the Wastebin count towards your quota usage. Automatically removing files from the Wastebin helps you stay within your quota limit.' 1 ''\''Automatically' remove files from Wastebin after 1 'day'\''' on 2 ''\''Automatically' remove files from Wastebin after 2 'days'\''' off 3 ''\''Automatically' remove files from Wastebin after 3 'days'\''' off 4 ''\''Automatically' remove files from Wastebin after 4 'days'\''' off 5 ''\''Automatically' remove files from Wastebin after 5 'days'\''' off 6 ''\''Automatically' remove files from Wastebin after 6 'days'\''' off 7 ''\''Automatically' remove files from Wastebin after 7 'days'\''' off
The quoting is clearly all screwed up when the variable is expanded for use with kdialog.

Can anyone explain how to get this to work? I've been mucking around with the quotes for about an hour and I'm completely stumped. Maybe
 
Old 06-12-2008, 02:12 PM   #2
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,021

Original Poster
Rep: Reputation: 172Reputation: 172
Solved it myself after reading through some other threads on here.

Code:
eval kdialog --radiolist "'Files in the Wastebin count towards your quota usage. Automatically removing files from the Wastebin helps you stay within your quota limit.'" $dialogoptions
I must confess I'm not entirely certain why it works, but it does.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash development - move chmod options to bash jhwilliams Programming 9 06-26-2007 12:13 PM
Generating iteratable arrays in bash d00bid00b Programming 4 08-15-2005 04:54 PM
bash scripting: problem with generating filenames mad_juno Programming 2 07-22-2005 10:57 AM
Bash way to tell if String is in String tongar Programming 3 06-16-2005 06:59 AM
Bash Script- Finding/Generating unique UserIDs pheasand Linux - General 2 12-11-2004 09:44 AM


All times are GMT -5. The time now is 09:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration