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.
This commit is contained in:
Profpatsch 2016-10-11 18:09:56 +02:00 committed by Franz Pletz
parent 8417c3aae1
commit bef6bef0d2
No known key found for this signature in database
GPG Key ID: 846FDED7792617B4
15 changed files with 27 additions and 22 deletions

View File

@ -1231,13 +1231,12 @@ echo @foo@
<term><function>stripHash</function> <term><function>stripHash</function>
<replaceable>path</replaceable></term> <replaceable>path</replaceable></term>
<listitem><para>Strips the directory and hash part of a store <listitem><para>Strips the directory and hash part of a store
path, storing the name part in the environment variable path, outputting the name part to <literal>stdout</literal>.
<literal>strippedName</literal>. For example: For example:
<programlisting> <programlisting>
stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
# prints coreutils-8.24 # prints coreutils-8.24
echo $strippedName stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
</programlisting> </programlisting>
If you wish to store the result in another variable, then the If you wish to store the result in another variable, then the
@ -1245,7 +1244,7 @@ echo $strippedName
<programlisting> <programlisting>
name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
someVar=$(stripHash $name; echo $strippedName) someVar=$(stripHash $name)
</programlisting> </programlisting>
</para></listitem> </para></listitem>

View File

@ -50,6 +50,14 @@ following incompatible changes:</para>
which prevents ptracing non-child processes. which prevents ptracing non-child processes.
This means you will not be able to attach gdb to an existing process, 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). 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> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>

View File

@ -12,7 +12,7 @@ for i in $scripts; do
if test "$(echo $i | cut -c1-2)" = "=>"; then if test "$(echo $i | cut -c1-2)" = "=>"; then
subDir=$(echo $i | cut -c3-) subDir=$(echo $i | cut -c3-)
else else
dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//') dst=$out/$subDir/$(stripHash $i | sed 's/\.in//')
doSub $i $dst doSub $i $dst
chmod +x $dst # !!! chmod +x $dst # !!!
fi fi
@ -23,7 +23,7 @@ for i in $substFiles; do
if test "$(echo $i | cut -c1-2)" = "=>"; then if test "$(echo $i | cut -c1-2)" = "=>"; then
subDir=$(echo $i | cut -c3-) subDir=$(echo $i | cut -c3-)
else else
dst=$out/$subDir/$((stripHash $i; echo $strippedName) | sed 's/\.in//') dst=$out/$subDir/$(stripHash $i | sed 's/\.in//')
doSub $i $dst doSub $i $dst
fi fi
done done

View File

@ -537,8 +537,7 @@ rec {
# Hacky: RPM looks for <basename>.spec inside the tarball, so # Hacky: RPM looks for <basename>.spec inside the tarball, so
# strip off the hash. # strip off the hash.
stripHash "$src" srcName="$(stripHash "$src")"
srcName="$strippedName"
cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
export HOME=/tmp/home export HOME=/tmp/home

View File

@ -41,7 +41,7 @@ stdenv.mkDerivation rec {
sourceRoot = "./"; sourceRoot = "./";
unpackCmd = '' unpackCmd = ''
ttfName=$(basename $(stripHash $curSrc; echo $strippedName)) ttfName=$(basename $(stripHash $curSrc))
cp $curSrc ./$ttfName cp $curSrc ./$ttfName
''; '';

View File

@ -54,7 +54,7 @@ stdenv.mkDerivation rec {
sourceRoot = "./"; sourceRoot = "./";
unpackCmd = '' unpackCmd = ''
ttfName=$(basename $(stripHash $curSrc; echo $strippedName)) ttfName=$(basename $(stripHash $curSrc))
cp $curSrc ./$ttfName cp $curSrc ./$ttfName
''; '';

View File

@ -30,7 +30,7 @@ stdenv.mkDerivation rec {
sourceRoot = "./"; sourceRoot = "./";
unpackCmd = '' unpackCmd = ''
ttfName=$(basename $(stripHash $curSrc; echo $strippedName)) ttfName=$(basename $(stripHash $curSrc))
cp $curSrc ./$ttfName cp $curSrc ./$ttfName
''; '';

View File

@ -3,5 +3,4 @@ source $stdenv/setup
mkdir -p $out/xml/dtd/docbook-ebnf mkdir -p $out/xml/dtd/docbook-ebnf
cd $out/xml/dtd/docbook-ebnf cd $out/xml/dtd/docbook-ebnf
cp -p $dtd dbebnf.dtd cp -p $dtd dbebnf.dtd
stripHash $catalog cp -p $catalog $(stripHash $catalog)
cp -p $catalog $strippedName

View File

@ -495,7 +495,7 @@ dumpVars() {
stripHash() { stripHash() {
strippedName=$(basename $1); strippedName=$(basename $1);
if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
strippedName=$(echo "$strippedName" | cut -c34-) echo "$strippedName" | cut -c34-
fi fi
} }

View File

@ -4,6 +4,6 @@ mkdir -p $out
for ((i = 1; i <= $nrFrames; i++)); do for ((i = 1; i <= $nrFrames; i++)); do
echo "producing frame $i..."; echo "producing frame $i...";
targetName=$out/$(basename $(stripHash $dotGraph; echo $strippedName) .dot)-f-$i.dot targetName=$out/$(basename $(stripHash $dotGraph) .dot)-f-$i.dot
cpp -DFRAME=$i < $dotGraph > $targetName cpp -DFRAME=$i < $dotGraph > $targetName
done done

View File

@ -185,7 +185,7 @@ rec {
if test -d $postscript; then if test -d $postscript; then
input=$(ls $postscript/*.ps) input=$(ls $postscript/*.ps)
else else
input=$(stripHash $postscript; echo $strippedName) input=$(stripHash $postscript)
ln -s $postscript $input ln -s $postscript $input
fi fi

View File

@ -4,7 +4,7 @@ mkdir -p $out
dot2pdf() { dot2pdf() {
sourceFile=$1 sourceFile=$1
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .dot).pdf targetName=$out/$(basename $(stripHash $sourceFile) .dot).pdf
echo "converting $sourceFile to $targetName..." echo "converting $sourceFile to $targetName..."
export FONTCONFIG_FILE=$fontsConf export FONTCONFIG_FILE=$fontsConf
dot -Tpdf $sourceFile > $targetName dot -Tpdf $sourceFile > $targetName

View File

@ -4,7 +4,7 @@ mkdir -p $out
dot2ps() { dot2ps() {
sourceFile=$1 sourceFile=$1
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .dot).ps targetName=$out/$(basename $(stripHash $sourceFile) .dot).ps
echo "converting $sourceFile to $targetName..." echo "converting $sourceFile to $targetName..."
dot -Tps $sourceFile > $targetName dot -Tps $sourceFile > $targetName
} }

View File

@ -10,7 +10,7 @@ cd $startDir
lhstex() { lhstex() {
sourceFile=$1 sourceFile=$1
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .lhs).tex targetName=$out/$(basename $(stripHash $sourceFile) .lhs).tex
echo "converting $sourceFile to $targetName..." echo "converting $sourceFile to $targetName..."
lhs2TeX -o "$targetName" $flags "$sourceFile" lhs2TeX -o "$targetName" $flags "$sourceFile"
} }

View File

@ -16,11 +16,11 @@ for i in $extraFiles; do
if test -d $i; then if test -d $i; then
ln -s $i/* . ln -s $i/* .
else else
ln -s $i $(stripHash $i; echo $strippedName) ln -s $i $(stripHash $i)
fi fi
done done
rootName=$(basename $(stripHash "$rootFile"; echo $strippedName)) rootName=$(basename $(stripHash "$rootFile"))
rootNameBase=$(echo "$rootName" | sed 's/\..*//') rootNameBase=$(echo "$rootName" | sed 's/\..*//')