Closed KEINOS closed 3 years ago
which
でコマンドのパスを返したら動きました。
#shellcheck shell=bash
# md5s は md5sum/md5 のラッパー関数です.
md5s() {
- if [ -e md5sum ]; then
- echo "$1" | md5sum
- elif [ -e md5 ]; then
+ if [ -e "$(which md5sum)" ]; then
+ echo "$1" | md5sum | awk '{ print $1 }'
+ elif [ -e "$(which md5)" ]; then
md5 -q -s "$1"
fi
}
Describe 'md5s'
It 'should return MD5 hash of the arg 1'
When call md5s 'hoge'
The output should equal 'c59548c3c576228486a1f0037eb16a1b'
The status should be success
End
End
$ shellspec --shell '/bin/bash' ./tests/md5s_test.sh
Running: /bin/bash [bash 5.1.0(1)-release]
.
Finished in 0.48 seconds (user 0.21 seconds, sys 0.08 seconds)
1 example, 0 failures
PR #25 で修正されているので Close します。何かあったら、再オープンよろです。
PR #5 の md5sum/md5 のラッパー関数が空の値を返します。
if [ -e md5sum ]
でコマンドの検知に失敗しているようです。