Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 23rd, 2005, 6:55 PM   #1
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Problem with aliasing

I'm using kdialog a lot in a Bash script, and I always use the option --title="$title". So I made an alias, alias kdialog="kdialog --title=\"$title\"". The line alias|grep kdialog in the script outputs alias kdialog='kdialog --title="Audio Konvert 0.3.0"', but the title of a dialog created with kdialog --yesno "test" has a title of "Question - KDialog."

I'm trying to keep this all in one script.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Dec 26th, 2005, 8:56 PM   #2
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Anyone?
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Dec 27th, 2005, 4:15 AM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Funny; it works for me. What version of KDE are you using?
Arevos is offline   Reply With Quote
Old Dec 27th, 2005, 8:37 AM   #4
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
notroot[0:~]& rpm -q kdebase
kdebase-3.5.0-0.1.fc4
notroot[0:~]&

Mabe it's something wrong with somethinge else in the script...? Should I attach it (It's 37KB)?
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Dec 27th, 2005, 10:38 AM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Same KDE version I have, so it's nothing to do with 3.5. Have you tried doing this normally?
title="Audio Konvert 0.3.0"
alias kdialog="kdialog --title=\"$title\""
kdialog --yesno "Testing, 1, 2, 3."
Arevos is offline   Reply With Quote
Old Dec 27th, 2005, 10:50 AM   #6
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Now try putting that in a shell script.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Dec 27th, 2005, 1:06 PM   #7
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by a thing
Now try putting that in a shell script.
Ah. I see what you mean. Curious indeed. Perhaps aliases are meant only for interactive use?

Perhaps use a function instead?
function kdialog
{
    /usr/bin/kdialog --title="$title" $*
}
I've put in the full path of kdialog in the function, because otherwise the function will recursively call itself.

Functions will only be around for the duration of the script, I believe (unless you put them in bashrc or similar), but they are called the same way you would call a regular command or alias:
kdialog --yesno "Testing, 1, 2, 3."
Arevos is offline   Reply With Quote
Old Dec 27th, 2005, 9:52 PM   #8
aznluvsmc
Hobbyist Programmer
 
Join Date: Aug 2005
Posts: 137
Rep Power: 4 aznluvsmc is on a distinguished road
Aliases are disabled for non-interactive shells (shell scripts) according to my book so I guess your experiment confirms it.
aznluvsmc is offline   Reply With Quote
Old Dec 27th, 2005, 11:07 PM   #9
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Good idea Arevos
#!/bin/bash
title="This is a test."
kdialog ()
{
	`kde-config --prefix`/bin/kdialog --title="$title $* #or $@
}
kdialog --yesno "Testing, 1, 2, 3."

almost works. The title works, but the content is "Testing," and excludes " 1, 2, 3."
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Dec 28th, 2005, 3:42 AM   #10
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
`kde-config --prefix`/bin/kdialog --title="$title $* #or $@
Aren't you missing a " after $title? Could that be what's wrong with it?
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC