QT Problems

Started by
11 comments, last by Floppy 22 years, 3 months ago
I fixed the problem; this is how I did it:

I re-installed Red Hat. One thing different that I noticed was in /etc/profile.d/qt.sh and qt.csh. These files are called by /etc/profile with this snippet of code:

for i in /etc/profile.d/*.sh ; do
if [ -r $i ]; then
. $i
fi
done

I don''t know much about shell scripting yet, but I can tell what it does. It basically loops through the /etc/profile.d/ directory looking for *.sh scripts then executes those scripts.

qt.sh looks like this:

# Qt initialization script (sh)
if [ -z "$QTDIR" ] ; then
QTDIR="/usr/lib/qt-2.3.1"
fi
export QTDIR

Makes sense so far? Well, here''s where it gets tricky. I had done essentially the EXACT same thing in my /etc/profile before I re-installed Red Hat. The only difference was that i didn''t have the if then statement just:
QTDIR="/usr/lib/qt-2.3.1"
export QTDIR

in my /etc/profile (and I created a qt.sh file and put that in there as well, but still no luck). Once again, I don''t know much shell scripting, but I assume it''s just checking whether or not $QTDIR has been defined and if not it defines it? then exports it as a global.

If you know more shell scripting than I do, and understand why this works and my way didn''t, please tell me.

Well, I am happy that I can finally build programs. Thanks for all your help!!
Advertisement
if [ -r $i ] makes sure than the file exists and is readable (you might want to enclose that one with "" to make sure a space in the name won''t screw the script)..

". $i" (source $i) executes the script ($i) in the same shell environment (meaning it can access the variables of the caller).

if [ -z "$QTDIR" ] checks if $QTDIR is an empty string. In this case, it will assign $QTDIR a value if it is empty, or only export it if it is not.

Just putting "export QTDIR=/usr/lib/qt-2.3.1" in your ~/.profile will work as long as you''re using a *login* shell. For interactive shells, you must use ~/.bashrc.

A common solution is to ''source'' .bashrc in .profile, like this :

test -r ~/.bashrc && . ~/.bashrc

or if you like longer (and maybe more readable) syntax:

if [ -r ~/.bashrc ]; then
. ~/.bashrc
fi

This will test if the file exists and is readable and, if so, sources it (the ''.'' is a shortcut to ''source''). That way, bashrc will be executed whenever you use a shell, so you can just put all your modifications in one file (bashrc).

I hope this makes sense .
Makes sense. Thanks!

This topic is closed to new replies.

Advertisement