checksum script

Darren Weber dweber at macports.org
Thu Jun 25 11:22:28 PDT 2009


Hi Jeremy,

The sed scrips do a bit of string replacement.

It seems the commands you listed below put the backslash on the next line,
rather than appended to the current line.  If you want to loop over multiple
input files, you might try $@, see:
http://www.mail-archive.com/freebsd-questions@freebsd.org/msg00400.html

Any other ideas?  The sed regex looks like a mess, but it's working
correctly.  It could be slightly more efficient with just one call to sed,

if [ -f "$1" ]; then
    basename $1 | sed -e "s/\(.*\)/\1 \\\/"
    md5 $1 | sed -e "s/^MD5.*=/md5/" -e "s/\(.*\)/\1 \\\/"
    openssl sha1 $1 | sed -e "s/^SHA1.*=/sha1/" -e "s/\(.*\)/\1 \\\/"
    openssl rmd160 $1 | sed -e "s/^R.*=/rmd160/"
fi

The if statement checks if the input is a regular file.

Anyhow, check the tips and tricks again, because port -v checksum offers a
nice alternative!
https://trac.macports.org/wiki/CommittersTipsAndTricks

Take care,
Darren


On Tue, Jun 23, 2009 at 11:00 AM, Jeremy Lavergne <
jeremy at lavergne.gotdns.org> wrote:

> If all those sed scripts calls for outputting the backslash, why not just
> use echo?
>
> for i in $1
> do
>    md5 "$i"; echo "\"
>    openssl sha1 "$i"; echo "\"
>    openssl rmd160 "$i"; echo "\"
> done
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20090625/70388917/attachment.html>


More information about the macports-dev mailing list