| Author |
Message |
tytower
Joined: 24 Feb 2007 Posts: 440 Location: Green Island Cairns for the winter
|
Posted: Mon 11 Jun 2012, 03:50 Post subject:
Syntax error in C shell script |
|
The following file is giving a syntax error on line 10
| Code: |
#!/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
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
Last edited by tytower on Mon 11 Jun 2012, 16:59; edited 2 times in total
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Mon 11 Jun 2012, 04:36 Post subject:
|
|
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.
|
|
Back to top
|
|
 |
tytower
Joined: 24 Feb 2007 Posts: 440 Location: Green Island Cairns for the winter
|
Posted: Mon 11 Jun 2012, 06:05 Post subject:
|
|
Yep thanks amigo --all true
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
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
jafadmin
Joined: 19 Mar 2009 Posts: 343
|
Posted: Mon 11 Jun 2012, 07:21 Post subject:
Re: Syntax error in C shell script |
|
Line 9 should be commented ..
| Code: |
#!/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
|
|
|
Back to top
|
|
 |
Keef

Joined: 20 Dec 2007 Posts: 428 Location: Staffordshire
|
Posted: Mon 11 Jun 2012, 13:51 Post subject:
|
|
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.
|
|
Back to top
|
|
 |
tytower
Joined: 24 Feb 2007 Posts: 440 Location: Green Island Cairns for the winter
|
Posted: Mon 11 Jun 2012, 16:55 Post subject:
|
|
Yes line 9 is commented . It was my mistake getting the code block to post right
Keef I agree thats what it is trying to do but it does not parse properly . Can you offer any correction or other approach ?
Here is the bash script for the same thing-It works fine
| Code: | #!/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
|
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
Last edited by tytower on Mon 11 Jun 2012, 17:59; edited 1 time in total
|
|
Back to top
|
|
 |
Keef

Joined: 20 Dec 2007 Posts: 428 Location: Staffordshire
|
Posted: Mon 11 Jun 2012, 17:29 Post subject:
|
|
I don't have qt, but it tried the first part of the script with empty folders (qt first, then qt-4)
| Code: | #!/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.
| Code: | QT4DIR= /usr/lib/qt-4321
PATH: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin:/root/my-applications/bin:/usr/games:/usr/lib/qt-4321/bin
CPLUS_INCLUDE_PATH: /usr/lib/qt-4321/include |
|
|
Back to top
|
|
 |
tytower
Joined: 24 Feb 2007 Posts: 440 Location: Green Island Cairns for the winter
|
Posted: Mon 11 Jun 2012, 17:54 Post subject:
|
|
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.
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
Keef

Joined: 20 Dec 2007 Posts: 428 Location: Staffordshire
|
Posted: Mon 11 Jun 2012, 18:06 Post subject:
|
|
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
| Code: |
line 10: syntax error near unexpected token `('
|
Can't think of anything else.
|
|
Back to top
|
|
 |
tytower
Joined: 24 Feb 2007 Posts: 440 Location: Green Island Cairns for the winter
|
Posted: Mon 11 Jun 2012, 23:50 Post subject:
|
|
I can get it to pass through by removing the brackets but that gives me an unexpected end of file message?
_________________ Neither my Family nor my Property are Government issues. Governments should do what they were designed to do Manage the larger issues best done by Governments
To stop corruption give them 3 times the penalty. Get their agreement on first employment.
|
|
Back to top
|
|
 |
|