Skip to content

Commit faa08bd

Browse files
committed
Avoid duplication of command -v
1 parent 299427a commit faa08bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rustup-init.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,16 @@ err() {
331331
}
332332

333333
need_cmd() {
334-
if ! command -v "$1" > /dev/null 2>&1
334+
if ! check_cmd "$1"
335335
then err "need '$1' (command not found)"
336336
fi
337337
}
338338

339+
check_cmd() {
340+
command -v "$1" > /dev/null 2>&1
341+
return $?
342+
}
343+
339344
need_ok() {
340345
if [ $? != 0 ]; then err "$1"; fi
341346
}
@@ -362,9 +367,9 @@ ignore() {
362367
# This wraps curl or wget. Try curl first, if not installed,
363368
# use wget instead.
364369
downloader() {
365-
if command -v curl > /dev/null 2>&1
370+
if check_cmd curl
366371
then _dld=curl
367-
elif command -v wget > /dev/null 2>&1
372+
elif check_cmd wget
368373
then _dld=wget
369374
else _dld='curl or wget' # to be used in error message of need_cmd
370375
fi

0 commit comments

Comments
 (0)