Ignore:
Timestamp:
03/20/2012 05:12:26 PM (13 years ago)
Author:
Pierre Labastie <pierre@…>
Branches:
ablfs
Children:
cd668b9
Parents:
c1decbe
Message:

Change script generation of root command: replace fragile construct
sudo sh -c '<commands>'
with slightly less fragile construct
sudo sh << ROOT_EOF
<commands with ` and \ escaped>
ROOT_EOF
Note: $ are not escaped, which is usually what is intended, but not always

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BLFS/xsl/scripts.xsl

    rc1decbe r970f2dc  
    437437        <xsl:when test="@role = 'root'">
    438438          <xsl:if test="$sudo = 'y'">
    439             <xsl:text>sudo sh -c '</xsl:text>
     439            <xsl:text>sudo sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
    440440          </xsl:if>
    441441          <xsl:apply-templates select="userinput" mode="root"/>
    442442          <xsl:if test="$sudo = 'y'">
    443             <xsl:text>'</xsl:text>
     443            <xsl:text>&#xA;ROOT_EOF</xsl:text>
    444444          </xsl:if>
    445445        </xsl:when>
     
    508508    <xsl:for-each select="child::node()">
    509509      <xsl:choose>
    510         <xsl:when test="self::text() and contains(string(),'make')">
    511           <xsl:value-of select="substring-before(string(),'make')"/>
    512           <xsl:text>make -j1</xsl:text>
    513           <xsl:value-of select="substring-after(string(),'make')"/>
     510        <xsl:when test="self::text()">
     511          <xsl:call-template name="output-root">
     512            <xsl:with-param name="out-string" select="string()"/>
     513          </xsl:call-template>
    514514        </xsl:when>
    515515        <xsl:otherwise>
     
    520520  </xsl:template>
    521521
     522  <xsl:template name="output-root">
     523    <xsl:param name="out-string" select="''"/>
     524    <xsl:choose>
     525      <xsl:when test="contains($out-string,'make')">
     526        <xsl:call-template name="output-root">
     527          <xsl:with-param name="out-string"
     528                          select="substring-before($out-string,'make')"/>
     529        </xsl:call-template>
     530        <xsl:text>make -j1</xsl:text>
     531        <xsl:call-template name="output-root">
     532          <xsl:with-param name="out-string"
     533                          select="substring-after($out-string,'make')"/>
     534        </xsl:call-template>
     535      </xsl:when>
     536      <xsl:when test="contains($out-string,'`')">
     537        <xsl:call-template name="output-root">
     538          <xsl:with-param name="out-string"
     539                          select="substring-before($out-string,'`')"/>
     540        </xsl:call-template>
     541        <xsl:text>\`</xsl:text>
     542        <xsl:call-template name="output-root">
     543          <xsl:with-param name="out-string"
     544                          select="substring-after($out-string,'`')"/>
     545        </xsl:call-template>
     546      </xsl:when>
     547      <xsl:when test="contains($out-string,'\')">
     548        <xsl:call-template name="output-root">
     549          <xsl:with-param name="out-string"
     550                          select="substring-before($out-string,'\')"/>
     551        </xsl:call-template>
     552        <xsl:text>\\</xsl:text>
     553        <xsl:call-template name="output-root">
     554          <xsl:with-param name="out-string"
     555                          select="substring-after($out-string,'\')"/>
     556        </xsl:call-template>
     557      </xsl:when>
     558      <xsl:otherwise>
     559        <xsl:value-of select="$out-string"/>
     560      </xsl:otherwise>
     561    </xsl:choose>
     562  </xsl:template>
     563
    522564  <xsl:template match="replaceable">
    523 <!-- Not needed anymore
    524     <xsl:choose>
    525       <xsl:when test="ancestor::sect1[@id='xorg7-server']">
    526         <xsl:text>$SRC_DIR/MesaLib</xsl:text>
    527       </xsl:when>
    528       <xsl:otherwise> -->
    529565        <xsl:text>**EDITME</xsl:text>
    530566        <xsl:apply-templates/>
    531567        <xsl:text>EDITME**</xsl:text>
    532 <!--      </xsl:otherwise>
    533     </xsl:choose> -->
    534568  </xsl:template>
    535569
Note: See TracChangeset for help on using the changeset viewer.