diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-08-06T09·06+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-08-06T09·06+0000 |
commit | 720f06e3b05502df2dc84afb7a3ad2ea5518246a (patch) | |
tree | e2334fc213fa5e11c98d7d208b9aac5ce05ee803 /src | |
parent | 37483672d425bc3b7be8e1deb049fd04c80be0cf (diff) |
* A flag `--flat' to just compute the MD5 checksum of the contents of
a regular file. I.e., `nix-hash --flat' is equivalent to the coreutils `md5sum' command (which doesn't exist on all systems).
Diffstat (limited to 'src')
-rw-r--r-- | src/nix-hash.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nix-hash.cc b/src/nix-hash.cc index e35d0a1feda3..77c169b9a952 100644 --- a/src/nix-hash.cc +++ b/src/nix-hash.cc @@ -6,9 +6,13 @@ void run(Strings args) { - for (Strings::iterator it = args.begin(); - it != args.end(); it++) - cout << format("%1%\n") % (string) hashPath(*it); + bool flat = false; + for (Strings::iterator i = args.begin(); + i != args.end(); i++) + if (*i == "--flat") flat = true; + else + cout << format("%1%\n") % (string) + (flat ? hashFile(*i) : hashPath(*i)); } |