Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

mingw-get is available at

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

After you have that installed run

mingw-get install msys-coreutils

share|improve this answer
    
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 wikipedia.org/wiki/PATH_%28variable%29 –  Steven Penny Jan 30 '12 at 1: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

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.