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?

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
mcgyver5
  • 1,101
  • 3
  • 11
  • 19

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
  • 24
  • 120
  • 163
  • thanks for your response. I downloaded it and ran the installer. Unfortunately, this is the result: Welcome to Git (version 1.7.4-preview20110204) McGuiT1@ISTM-L-6328MJ1 ~ $ mingw-get install mysys-coreutils sh.exe": mingw-get: command not found – mcgyver5 Jan 29 '12 at 23:55
  • 1
    You need to add mingw-get to your path http://wikipedia.org/wiki/PATH_%28variable%29 – Zombo Jan 30 '12 at 01:25
  • 1
    update: I successfully installed mingw-get and then msys-coreutils, but sha1sum command still not found – mcgyver5 Nov 26 '13 at 23:07
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
thetabit
  • 19
  • 1