2020-03-02 00:22:10 +08:00
|
|
|
function __fish_md5
|
2017-05-13 19:28:32 +08:00
|
|
|
if type -q md5sum
|
|
|
|
# GNU systems
|
|
|
|
if set -q argv[2]
|
2020-03-10 02:36:12 +08:00
|
|
|
if test $argv[1] = -s
|
2017-05-13 19:28:32 +08:00
|
|
|
echo (echo $argv[2] | md5sum | string split ' ')[1]
|
|
|
|
else
|
|
|
|
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv
|
|
|
|
end
|
|
|
|
else
|
|
|
|
echo (md5sum $argv[1] | string split ' ')[1]
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
else if type -q md5
|
|
|
|
# BSD systems
|
|
|
|
if set -q argv[2]
|
2020-03-10 02:36:12 +08:00
|
|
|
if test $argv[1] = -s
|
2017-05-13 19:28:32 +08:00
|
|
|
md5 -s $argv[1]
|
|
|
|
else
|
|
|
|
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv
|
|
|
|
end
|
|
|
|
else
|
|
|
|
md5 -q $argv[1]
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
return 1
|
|
|
|
end
|