5

I've been using git-bash on Windows 7 a lot. I gather it is a wrapper of MinGW. It has md5sum but not sha1sum. I'd like to install sha1sum, but I can't figure out how.

When I try mingw-get, it says "command not found"

When I tried to download mingw-get from SourceForge, I only found an installer for the entire MinGW program but not for mingw-get.

How do I install either getting sha1sum or getting mingw-get?

mcgyver5
  • 1,121

2 Answers2

6

mingw-get is available at

sourceforge.net/projects/mingw/files/Installer/mingw-get

After you have that installed run

mingw-get install msys-coreutils

Zombo
  • 1
1

I solved this for myself by adding a shell function that uses the included openssl to replace the part of sha1sum that I used most often.

function openssl_sha1sum() {
    local i nf=0 binary= text=true
    local -a files

    # parse for -b/-t mode output arguments
    for (( i=1; i <= $#; i++ )); do
        case "${!i}" in
            (-t|--text)
                text=true
                binary=
                ;;
            (-b|--binary)
                binary=true
                text=
                ;;
            (-|-[cw]|--help|--version|--status|--check|--warn)
                ;;
            (*)
                let 'nf++'
                files[$nf]="${!i}"
                ;;
        esac
    done

    # execute the appropriate command and reformat the output
    if [ $nf -eq 0 ]; then
        local binfmt='s/$/ *-/;' txtfmt='s/$/  -/;'
        if [ -n "$binary" ]; then
            fmt=$binfmt
        else
            fmt=$txtfmt
        fi
        openssl dgst -sha1 -hex | sed -e "$fmt"
    else
        local commonfmt='s/^[A-Z0-9]\+(\(.*\))= \([0-9a-fA-F]\+\)$/\2'
        local binfmt="$commonfmt "'*\1/;' txtfmt="$commonfmt  "'\1/;'
        if [ -n "$binary" ]; then
            fmt=$binfmt
        else
            fmt=$txtfmt
        fi
        openssl dgst -sha1 -hex "${files[@]}" | sed -e "$fmt"
    fi
}

if ! type -p sha1sum &>/dev/null; then
    function sha1sum() { openssl_sha1sum "$@"; }
fi