2020-03-01 16:22:10 +00:00
|
|
|
function __fish_md5
|
2017-05-13 11:28:32 +00:00
|
|
|
if type -q md5sum
|
|
|
|
# GNU systems
|
|
|
|
if set -q argv[2]
|
2020-03-09 18:36:12 +00:00
|
|
|
if test $argv[1] = -s
|
2024-04-04 14:27:37 +00:00
|
|
|
echo $argv[2] | md5sum | string split ' ' -f 1
|
2017-05-13 11:28:32 +00:00
|
|
|
else
|
2022-04-04 03:57:55 +00:00
|
|
|
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv >&2
|
2017-05-13 11:28:32 +00:00
|
|
|
end
|
|
|
|
else
|
2024-04-04 14:27:37 +00:00
|
|
|
md5sum $argv[1] | string split ' ' -f 1
|
2017-05-13 11:28:32 +00:00
|
|
|
end
|
|
|
|
return 0
|
|
|
|
else if type -q md5
|
|
|
|
# BSD systems
|
|
|
|
if set -q argv[2]
|
2020-03-09 18:36:12 +00:00
|
|
|
if test $argv[1] = -s
|
2020-04-05 21:27:59 +00:00
|
|
|
md5 -s $argv[2]
|
2017-05-13 11:28:32 +00:00
|
|
|
else
|
2022-04-04 03:57:55 +00:00
|
|
|
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv >&2
|
2017-05-13 11:28:32 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
md5 -q $argv[1]
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
return 1
|
|
|
|
end
|