Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use 'command -v' instead of 'which' in bash scripts #581

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/release/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cd "${REPO_ROOT}"

# darwin is great
SED="sed"
if which gsed &>/dev/null; then
if command -v gsed &>/dev/null; then
SED="gsed"
fi
if ! (${SED} --version 2>&1 | grep -q GNU); then
Expand Down
4 changes: 2 additions & 2 deletions hack/util/goarch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# this script attempts to print GOARCH for the host

# if we have go, just ask go!
if which go >/dev/null 2>&1; then
if command -v go >/dev/null 2>&1; then
go env GOARCH
exit $?
fi

# fall back to uname
if which uname >/dev/null 2>&1; then
if command -v uname >/dev/null 2>&1; then
case "$(uname -m)" in
x86_64)
echo "amd64"
Expand Down
2 changes: 1 addition & 1 deletion hack/util/goinstalldir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# this utility prints out the golang install dir even if go is not installed

# if we have go, just ask go!
if which go >/dev/null 2>&1; then
if command -v go >/dev/null 2>&1; then
DIR=$(go env GOBIN)
if [ -n "${DIR}" ]; then
echo "${DIR}"
Expand Down
4 changes: 2 additions & 2 deletions hack/util/goos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# this script attempts to print GOOS for the host

# if we have go, just ask go!
if which go >/dev/null 2>&1; then
if command -v go >/dev/null 2>&1; then
go env GOOS
exit $?
fi
Expand All @@ -36,7 +36,7 @@ if [ -n "${OSTYPE:-}" ]; then
fi

# fall back to uname
if which uname >/dev/null 2>&1; then
if command -v uname >/dev/null 2>&1; then
case "$(uname -s)" in
Darwin)
echo "darwin"
Expand Down
2 changes: 1 addition & 1 deletion images/kindnetd/push-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ARCHES=(

# darwin is great
SED="sed"
if which gsed &>/dev/null; then
if command -v gsed &>/dev/null; then
SED="gsed"
fi
if ! (${SED} --version 2>&1 | grep -q GNU); then
Expand Down