Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-4704

Unwanted variable interpolation in shell scripts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.1.0
    • 4.1.0
    • karaf

    Description

      There is a variable interpolation problem in the shell scripts "/bin/shell", "/bin/start", "/bin/client", ... of Karaf 4.1.0-SNAPSHOT. All affected files can be found here: https://github.com/apache/karaf/tree/master/assemblies/features/base/src/main/filtered-resources/resources/bin).

      Because the shell scripts get filtered by Maven, the variable ${PWD} gets accidently replaced during the build process by "/home/jenkins/jenkins-slave". I am refering to the nightly builds available in the Apache Snapshot Repository: https://repository.apache.org/content/groups/snapshots-group/org/apache/karaf/apache-karaf/4.1.0-SNAPSHOT/

      IS:
      realpath() {
      OURPWD=/home/jenkins/jenkins-slave
      cd "$(dirname "${1}")"
      LINK=$(readlink "$(basename "${1}")")
      while [ "${LINK}" ]; do
      cd "$(dirname "${LINK}")"
      LINK=$(readlink "$(basename "${1}")")
      done
      REALPATH="/home/jenkins/jenkins-slave/$(basename "${1}")"
      cd "${OURPWD}"
      echo "${REALPATH}"
      }

      SHOULD:
      realpath() {
      OURPWD=${PWD}
      cd "$(dirname "${1}")"
      LINK=$(readlink "$(basename "${1}")")
      while [ "${LINK}" ]; do
      cd "$(dirname "${LINK}")"
      LINK=$(readlink "$(basename "${1}")")
      done
      REALPATH="${PWD}/$(basename "${1}")"
      cd "${OURPWD}"
      echo "${REALPATH}"
      }

      We can replace ${PWD} by \${PWD}, whereas "\" is the default escapeString. But we should find a solution that avoids unwanted interpolation at all. The best solution would be to define a custom delimiter for the Maven resource plugin which does not overlap with statements within the shell code.

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            herr-herner Jens Offenbach
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: