use shell built-in `command' instead of which(1)

it's specified by POSIX AFAIK and requires less redirections.
This commit is contained in:
Omar Polo 2022-02-27 16:24:45 +00:00
parent cd3e28ffe4
commit 12fcba2f80
1 changed files with 2 additions and 2 deletions

View File

@ -3,11 +3,11 @@
# USAGE: ./sha in out
# writes the sha256 of in to file out
if which sha256 2>/dev/null >/dev/null; then
if command -v sha256 >/dev/null; then
exec sha256 < "$1" > "$2"
fi
if which sha256sum 2>/dev/null >/dev/null; then
if command -v sha256sum >/dev/null; then
sha256sum "$1" | awk '{print $1}' > "$2"
exit $?
fi