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>
<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>

View file

@ -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>

View file

@ -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

View file

@ -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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,6 +4,6 @@ mkdir -p $out
for ((i = 1; i <= $nrFrames; i++)); do
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
done

View file

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

View file

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

View file

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

View file

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

View file

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