How do I read and display a shell script that contains shell variables like ${0}?

Comments

1 comment

  • Avatar
    juanjo

    This is a current limitation. You could use the below custom action, and use <readFileEscapeVars> instead of <readFile>:

    <project>
         ...
        <functionDefinitionList>
          <actionDefinition>
            <name>readFileEscapeVars</name>
            <actionList>
              <globalVariables names="${variable}"/>
              <createTimeStamp variable="timestamp"/>
              <setInstallerVariable name="tmpFile" value="${system_temp_directory}/tmp-${timestamp}.txt"/>
              <copyFile origin="${file}" destination="${tmpFile}"/>
              <substitute>
                <files>${tmpFile}</files>
                <type>exact</type>
                <substitutionList>
                  <substitution pattern="${" value="@@DOLLAR_CHAR@@{"/>
                </substitutionList>
              </substitute>
              <readFile name="${variable}" path="${tmpFile}"/>
              <setInstallerVariableFromRegEx>
                <name>${variable}</name>
                <pattern>@@DOLLAR_CHAR@@\{([^\n\}]*)\}</pattern>
                <substitution>@@VAR_REFERENCE@@(\1)</substitution>
                <text>${${variable}}</text>
              </setInstallerVariableFromRegEx>
              <setInstallerVariableFromRegEx>
                <name>${variable}</name>
                <pattern>@@DOLLAR_CHAR@@</pattern>
                <substitution>$</substitution>
                <text>${${variable}}</text>
              </setInstallerVariableFromRegEx>
              <setInstallerVariableFromRegEx>
                <name>${variable}</name>
                <pattern>@@VAR_REFERENCE@@\(([^\)]*)\)</pattern>
                <substitution>${'${'${\1}'}'}</substitution>
                <text>${${variable}}</text>
              </setInstallerVariableFromRegEx>
              <deleteFile path="${tmpFile}"/>
            </actionList>
            <parameterList>
              <stringParameter name="file" value="" default=""/>
              <stringParameter name="variable" value="" default=""/>
            </parameterList>
          </actionDefinition>
        </functionDefinitionList>
       <initializationActionList>
            <readFileEscapeVars file="${filePath}" variable="file_content"/>
            <showText>
                <text>${file_content}</text>
                <title>${filePath}</title>
            </showText>
        </initializationActionList>
    </project>
    

Please sign in to leave a comment.