bashexit-codesha1sum

What are sha1sum "exit codes"?


1) Is there any documentation/URL about sha1sum "exit codes"? I am just want to be sure, that "exit code 1" always means that there is a "FAILED result".

$ sha1sum dummy* > SHA1SUM
$ sha1sum -c SHA1SUM 
dummy1: OK
dummy2: OK
dummy3: OK
$ echo $?
0
$ ls > dummy1
$ sha1sum -c SHA1SUM 
dummy1: FAILED
dummy2: OK
dummy3: OK
sha1sum: WARNING: 1 computed checksum did NOT match
$ echo $?
1
$ ls > dummy2
$ sha1sum -c SHA1SUM 
dummy1: FAILED
dummy2: FAILED
dummy3: OK
sha1sum: WARNING: 2 computed checksums did NOT match
$ echo $?
1

Solution

  • Exit code 1 can mean other errors, for instance permission failure or file not found (which will be counted as a FAILED result though).

    touch foo
    sha1sum foo > foo.sha1
    mv foo bar
    sha1sum foo.sha1 # will fail with $? == 1