Uploaded image for project: 'Blazegraph (by SYSTAP)'
  1. Blazegraph (by SYSTAP)
  2. BLZG-1567

Shell scripts must quote environment variables

    XMLWordPrintable

    Details

      Description

      I first noticed this for ./scripts/prog.sh. It uses the following incantations:

      if [ -z $JAVA_OPTS ] ; then
      	JAVA_OPTS="-ea -Xmx4g -server"
      fi
      
      if [ -z $JAVA_HOME ] ; then
      	JAVA=${JAVA_HOME}/bin/java
      else
      	JAVA=`which java`
      fi
      

      However if there is white space in either JAVA_OPTS or JAVA_HOME then these incantations will break.

      Also, JAVA should be quoted as used below in case the file path has whitespace (quotes are missing in the original).

      "$JAVA" ${JAVA_OPTS} -cp bigdata-jar/target/bigdata-jar*.jar $*
      

      Finally note that JAVA_OPTS MUST NOT be quoted when it is being passed through to Java, so the following is correct.

      "$JAVA" ${JAVA_OPTS} -cp bigdata-jar/target/bigdata-jar*.jar $*
      

        Attachments

          Activity

            People

            Assignee:
            beebs Brad Bebee
            Reporter:
            bryanthompson bryanthompson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: