#! /bin/sh -e # $Id$ # $URL$ # Copyright (C) 2006, 2007 Tilburg University # # This file is part of uvt-sum. uvt-sum is free software; you can redistribute # it and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the License, # or (at your option) any later version. You should have received a copy of # the GNU General Public License along with this file (see COPYING). read -r sum origfile case $# in 0) file="$(mktemp)" trap 'rm -f "$file"' 0 cat >"$file" echo "$sum $file" | md5sum -c exec <"$file" exec cat ;; 1) file="$1" trap 'rm -f "$file,$$"' 0 cat >"$file,$$" echo "$sum $file,$$" | md5sum -c mv "$file,$$" "$file" ;; *) echo "Too many arguments, usage: $0 [filename]" >&2 exit 2 esac