tags:

views:

28

answers:

2

I'm bad at bash programming. Where is the error? Here is my .profile file:

# WARNING: For help understanding this file, and before you try
# to change any of it, type "man .profile" and read carefully.
#

#
# Set command search rules
#
if [ -x /bin/showpath ] ; then  
    export PATH; PATH=`/bin/showpath $HOME/bin /u/cs350/sys161/bin /software/gnu/bin standard`
    export PATH; PATH=`/bin/showpath usedby=user standard $HOME/bin`
#
# Find out what kind of terminal we are using
#
    eval `setterm  sytek:kd404  default:vc404`
#
# Set terminal-type dependent options (e.g. sysline or prompt string)
#
    #HOMEHOST="<hostname>"
    #HOMEUSER="<userid>"
    #export HOMEHOST HOMEUSER
    PS1="$ "
#
# Now do the usual signing on things
#
    export MAIL; MAIL=${MAIL-"/usr/spool/mail/$USER"}

if [ -r /software/.admin/bins/bin/read_system_news ] ; then /software/.admin/bins/bin/read_system_news ; fi

EOF
+3  A: 

Your first if is missing a fi.

Ignacio Vazquez-Abrams
+1  A: 

You are missing a fi at the end of file add it.

Also get rid of EOF. The EOF in your case is treated as a command.

Sometimes running your script using different shells gives you a clue about the error.

When we run your program using:

  • sh it says Syntax error: end of file unexpected (expecting "fi")
  • csh it says if: Expression Syntax.
codaddict
Running a bash or sh script through csh is guaranteed to give you errors. It's just a coincidence that the error you show seems relevant.
Dennis Williamson
@Dennis: Only if your bash script happens to use bash specific features.
codaddict
@codaddict: No, csh uses parentheses `if ( condition )` - not square brackets.
Dennis Williamson