#!/bin/csh
# Environment path variables for the Qt package:
if ( ! $?QT4DIR ) then
# It's best to use the generic directory to avoid
# compiling in a version-containing path:
if ( -d /usr/lib/qt ) then
setenv QT4DIR /usr/lib/qt
else
# Find the newest Qt directory and set $QT4DIR to that:
foreach qtd ( /usr/lib/qt-* ) ********************************
if ( -d $qtd ) then
setenv QT4DIR $qtd
endif
end
endif
endif
set path = ( $path $QT4DIR/bin )
if ( $?CPLUS_INCLUDE_PATH ) then
setenv CPLUS_INCLUDE_PATH $QT4DIR/include:$CPLUS_INCLUDE_PATH
else
setenv CPLUS_INCLUDE_PATH $QT4DIR/include
endif
I don't understand how that line works or even why it is being seen as the previous condition has been met . Can anyone explain it for me?
Especially the " qt-*" bit- How does it get a list from that?
The qt4 directory is set OK to /usr/lib/qt
Last edited by tytower on Mon 11 Jun 2012, 20:59, edited 2 times in total.
You don't quote the error, so we can't help much. Also, the script uses csh which is not very common anymore. You might wish to convert the script to use bash instead -of course you need to understand exactly what the script is supposed to do...
It looks as if it is a script for setting up the qt4 environment -probably being run from /etc/profile.d ??? If so, there are also bash/shell versions of that script around.
I want to understand why line 10 does not work. foreach qtd ( /usr/lib/qt-* )
In particular the " qt-* " piece
the * of course is a match any character
the qtd is a variable to hold the directory list element which is part of a list supplied by /usr/lib/qt-*
I dont know what the "-" does or if it is correct
The error message is as stated - Syntax error in line 10
#!/bin/csh
# Environment path variables for the Qt package:
if ( ! $?QT4DIR ) then
# It's best to use the generic directory to avoid
# compiling in a version-containing path:
if ( -d /usr/lib/qt ) then
setenv QT4DIR /usr/lib/qt
else
# Find the newest Qt directory and set $QT4DIR to that:
foreach qtd ( /usr/lib/qt-* )
if ( -d $qtd ) then
setenv QT4DIR $qtd
endif
end
endif
endif
set path = ( $path $QT4DIR/bin )
if ( $?CPLUS_INCLUDE_PATH ) then
setenv CPLUS_INCLUDE_PATH $QT4DIR/include:$CPLUS_INCLUDE_PATH
else
setenv CPLUS_INCLUDE_PATH $QT4DIR/include
endif
It looks like that section of code is checking for a generic qt directory, or if there isn't one, use one with a version number, eg qt-4.3 or whatever.
I'm sure it could be written in many different ways.
#!/bin/sh
# Environment variables for the Qt package.
#
# It's best to use the generic directory to avoid
# compiling in a version-containing path:
if [ -d /usr/lib/qt ]; then
QT4DIR=/usr/lib/qt
else
# Find the newest Qt directory and set $QT4DIR to that:
for qtd in /usr/lib/qt-* ; do
if [ -d $qtd ]; then
QT4DIR=$qtd
fi
done
fi
if [ ! "$CPLUS_INCLUDE_PATH" = "" ]; then
CPLUS_INCLUDE_PATH=$QT4DIR/include:$CPLUS_INCLUDE_PATH
else
CPLUS_INCLUDE_PATH=$QT4DIR/include
fi
PATH="$PATH:$QT4DIR/bin"
export QT4DIR
export CPLUS_INCLUDE_PATH
Last edited by tytower on Mon 11 Jun 2012, 21:59, edited 1 time in total.
#!/bin/sh
# Environment variables for the Qt package.
#
# It's best to use the generic directory to avoid
# compiling in a version-containing path:
if [ -d /usr/lib/qt ]; then
QT4DIR=/usr/lib/qt
else
# Find the newest Qt directory and set $QT4DIR to that:
for qtd in /usr/lib/qt-* ; do
if [ -d $qtd ]; then
QT4DIR=$qtd
fi
done
fi
####################
echo "QT4DIR=" $QT4DIR
It came up with '/usr/lib/qt' then '/usr/lib/qt-4' as expected.
In fact if I run the whole script and then 'echo' PATH and CPLUS_INCLUDE_PATH
they look to be correct.
Yes the bash script runs with no errors and gets it right
The csh script however is the one giving the error.
I notice on my machine in /etc/profile.d/ I have both versions of the script
I think an extra has been brought in from KeePassx or KeePass2 which I was trying to install
I also notice each time I open the console I get the error message in the console so it must run all the profile.d scripts each time it opens .
That is telling me I don't need qt4.csh in there anyway as it is getting set up by qt4.sh . So I removed it and am now not getting the error messages
Would still like to know why line 10 of qt4.csh gives an error as it looks OK to me too.
I think it may just be that csh is just a symlink to bash, and it doesn't like the different format.
'#!/bin/csh' won't run the script on Wary 5.3, but changing it to #!/bin/sh gives