From e71a5cb87841f0af4a2279517b77a9a07ba394c0 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Thu, 23 Jun 2016 11:53:45 +0100 Subject: 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. --- doc/stdenv.xml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/doc/stdenv.xml b/doc/stdenv.xml index b075e0219a545..99c5d30c2db9a 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -1191,31 +1191,35 @@ echo @foo@ file. - - - stripHash - path + + + baseHash + path + suffix + Strips the directory and hash part of a store path, storing the name part in the environment variable - strippedName. For example: + strippedName. If suffix is also + provided, the suffix will also be removed. For example: -stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" +baseHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" # prints coreutils-8.24 -echo $strippedName - If you wish to store the result in another variable, then the - following idiom may be useful: - -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 + - + + stripHash + path + Deprecated. Use baseHash instead. + -- cgit 1.4.1