Unverified Commit bef6bef0 authored by Profpatsch's avatar Profpatsch Committed by Franz Pletz
Browse files

stdenv/stripHash: print to stdout, not to variable

`stripHash` documentation states that it prints out the stripped name to
the stdout, but the function stored the value in `strippedName`
instead.

Basically all usages did something like
`$(stripHash $foo | echo $strippedName)` which is just braindamaged.
Fixed the implementation and all invocations.
parent 8417c3aa
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1231,13 +1231,12 @@ echo @foo@
    <term><function>stripHash</function>
    <replaceable>path</replaceable></term>
    <listitem><para>Strips the directory and hash part of a store
    path, storing the name part in the environment variable
    <literal>strippedName</literal>. For example:
    path, outputting the name part to <literal>stdout</literal>.
    For example:
    
<programlisting>
stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
# prints coreutils-8.24
echo $strippedName
stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
</programlisting>

    If you wish to store the result in another variable, then the
@@ -1245,7 +1244,7 @@ echo $strippedName
    
<programlisting>
name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
someVar=$(stripHash $name; echo $strippedName)
someVar=$(stripHash $name)
</programlisting>

    </para></listitem>
+8 −0
Original line number Diff line number Diff line
@@ -50,6 +50,14 @@ following incompatible changes:</para>
      which prevents ptracing non-child processes.
      This means you will not be able to attach gdb to an existing process,
      but will need to start that process from gdb (so it is a child).
  </listitem>

  <listitem>
    <para>
      The <literal>stripHash</literal> bash function in <literal>stdenv</literal>
      changed according to its documentation; it now outputs the stripped name to
      <literal>stdout</literal> instead of putting it in the variable
      <literal>strippedName</literal>.
    </para>
  </listitem>
</itemizedlist>
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ for i in $scripts; do
    if test "$(echo $i | cut -c1-2)" = "=>"; then
        subDir=$(echo $i | cut -c3-)
    else
        dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
        dst=$out/$subDir/$(stripHash $i | sed 's/\.in//')
        doSub $i $dst
        chmod +x $dst # !!!
    fi
@@ -23,7 +23,7 @@ for i in $substFiles; do
    if test "$(echo $i | cut -c1-2)" = "=>"; then
        subDir=$(echo $i | cut -c3-)
    else
        dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//')
        dst=$out/$subDir/$(stripHash $i | sed 's/\.in//')
        doSub $i $dst
    fi
done
+1 −2
Original line number Diff line number Diff line
@@ -537,8 +537,7 @@ rec {

      # Hacky: RPM looks for <basename>.spec inside the tarball, so
      # strip off the hash.
      stripHash "$src"
      srcName="$strippedName"
      srcName="$(stripHash "$src")"
      cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root

      export HOME=/tmp/home
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
  sourceRoot = "./";

  unpackCmd = ''
    ttfName=$(basename $(stripHash $curSrc; echo $strippedName))
    ttfName=$(basename $(stripHash $curSrc))
    cp $curSrc ./$ttfName
  '';

Loading