Mercurial > ec-dotfiles
view bin/cek @ 6:2ae8e6222b9d
Added inputrc.
author | Edho Prima Arief <me@myconan.net> |
---|---|
date | Mon, 19 Jul 2010 16:47:48 +0700 |
parents | 94ee419ad047 |
children | 8fc79d327ccd |
line wrap: on
line source
#!/bin/sh bn() { basename "/$*"; } #cs() { cksfv -- "$@"; } cs() { cek.rb "$@"; } if [ "$#" -lt 1 ]; then cat <<EOF Usage: $(bn "$0") file1 file2 ... fileN EOF exit 1 fi file_ok=0 file_unre=0 file_err=0 file_nocrc=0 for file in "$@"; do st="nofile" if [ -f "${file}" ] && [ -r "${file}" ]; then crc=$(cs "${file}" | tail -1 | sed -e 's/.*\([A-F0-9]\{8\}\)$/\1/') nocrc=$(bn "${file}" | sed -e 's/.*[[(][A-Fa-f0-9]\{8\}[])].*//') st="nocrc" if [ ! -n "${nocrc}" ]; then # the filename has CRC. Yay filecrc=$(bn "${file}" | sed -e 's/.*[[(]\([A-Fa-f0-9]\{8\}\)[])].*/\1/;y/abcdef/ABCDEF/') if [ "${filecrc}" = "${crc}" ]; then st="fileok" file_ok=$((file_ok+1)) else st="filerr" file_err=$((file_err+1)) fi else st="nocrc" file_nocrc=$((file_nocrc+1)) fi else st="nofile" file_unre=$((file_unre+1)) fi case "${st}" in "nofile") ret="not a file or unreadable";; "nocrc") ret="${crc}";; "fileok") ret="${crc} - OK!";; "filerr") ret="${crc} - ERROR - should be ${filecrc}";; esac printf "%s\n" "${file}: ${ret}" done echo "--------------------------------" [ "${file_ok}" -gt 0 ] && echo "Files ok: ${file_ok}" [ "${file_err}" -gt 0 ] && echo "Files broken: ${file_err}" [ "${file_nocrc}" -gt 0 ] && echo "Files without crc information: ${file_nocrc}" [ "${file_unre}" -gt 0 ] && echo "Files unreadable or not file: ${file_unre}"