diff options
author | zimbatm <zimbatm@zimbatm.com> | 2016-06-23 11:53:45 +0100 |
---|---|---|
committer | zimbatm <zimbatm@zimbatm.com> | 2016-06-25 14:20:56 +0100 |
commit | e71a5cb87841f0af4a2279517b77a9a07ba394c0 (patch) | |
tree | c233b5bc126f79effc16d5b9ac60bfa3f1c1ea64 /doc/stdenv.xml | |
parent | 7060eaf0bb98f3b4b6d10e7e55d20df9527866bf (diff) | |
download | nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.tar nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.tar.gz nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.tar.bz2 nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.tar.lz nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.tar.xz nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.tar.zst nixlib-e71a5cb87841f0af4a2279517b77a9a07ba394c0.zip |
stdenv: introduce baseHash() to replace stripHash()
stripHash uses a global variable to communicate it's computation results, but it's not necessary. You can just pipe to stdout in a subshell. A function mostly behaves like just another command. baseHash() also introduces a suffix-stripping capability since it's something the users of the function tend to use.
Diffstat (limited to 'doc/stdenv.xml')
-rw-r--r-- | doc/stdenv.xml | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/doc/stdenv.xml b/doc/stdenv.xml index b075e0219a54..99c5d30c2db9 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -1191,31 +1191,35 @@ echo @foo@ <replaceable>file</replaceable>.</para></listitem> </varlistentry> - - <varlistentry xml:id='fun-stripHash'> - <term><function>stripHash</function> - <replaceable>path</replaceable></term> + <varlistentry xml:id='fun-baseHash'> + <term> + <function>baseHash</function> + <replaceable>path</replaceable> + <replaceable>suffix</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: + <literal>strippedName</literal>. If <literal>suffix</literal> is also + provided, the suffix will also be removed. For example:</para> <programlisting> -stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" +baseHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" # prints coreutils-8.24 -echo $strippedName </programlisting> - If you wish to store the result in another variable, then the - following idiom may be useful: - <programlisting> -name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" -someVar=$(stripHash $name; echo $strippedName) +baseHash "/nix/store/0016702zbydafsr20n9l1dcw7x2bf6jj-arraysugar-0.1.0.gem" .gem +# prints arraysugar-0.1.0 </programlisting> + </listitem> - </para></listitem> </varlistentry> + <varlistentry xml:id='fun-stripHash'> + <term><function>stripHash</function> + <replaceable>path</replaceable></term> + <listitem><para>Deprecated. Use baseHash instead.</para></listitem> + </varlistentry> </variablelist> |