bash catenate strings right to left

46 Views Asked by At

I'm debugging this catalina.sh script, at this point:

echo "$CATALINA_HOME"
  echo "dot " .
  echo "179"
  if [ -r "$CATALINA_HOME"/bin/setclasspath.sh ]; then
    echo "qui 81"

    . "$CATALINA_HOME"/bin/setclasspath.sh
  else
    echo "185"
    echo "Cannot find $CATALINA_HOME/bin/setclasspath.sh"
    echo "This file is needed to run this program"
    exit 1
  fi

output is:

 /home/sysadm/2_KNOWAGE/Knowage_6-2_ARES/Knowage-Server-CE 
 dot  . 
 179
 185
 /bin/setclasspath.shsadm/2_KNOWAGE/Knowage_6-2_ARES/Knowage-Server-CE
 This file is needed to run this program

when actually setclasspath.sh exixts, has write permissions and is where it's supposed to be. So I expect it to be found and run.

1

There are 1 best solutions below

0
On BEST ANSWER

The problem is almost certainly to do with line endings. I strongly suspect that CATALINA_HOME is picking up a carriage return character because it has been saved with Windows line endings.

Try running the script through dos2unix to strip the carriage returns.

You might also want to check that your editor is set to use Unix line ends rather than Windows ones.