-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
kubectl binary search #145
Comments
Okay, what can be done about this?
tis 25 juli 2023 kl. 11:28 skrev Eugene Paskevich ***@***.***
:
Hi!
Script fails to find kubectl binary in case path hashing is disabled with set
+o hashall or set +h.
—
Reply to this email directly, view it on GitHub
<#145>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABNVFJMVMJZXNER5PW5SEDXR6GTFANCNFSM6AAAAAA2WY4R2U>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Sent from my phone
|
Mmm.. I guess we have two options. Either switch from using hash function to something else like whereis or which, or add a |
@Crazy-Hopper I'm not familiar with this, unfortunately. Do you know if this will have any other impact? Will it be backward-compatible? |
It seems to me that But frankly, I'd rewrite the initial code as follows: diff --git a/kubetail b/kubetail
index 9c7464b..d34ab38 100755
--- a/kubetail
+++ b/kubetail
@@ -1,15 +1,15 @@
#!/bin/bash
+
if [ -z "${KUBECTL_BIN}" ]; then
- if hash kubectl 2>/dev/null; then
- KUBECTL_BIN='kubectl'
- elif hash kubectl.exe 2>/dev/null; then
- KUBECTL_BIN='kubectl.exe'
- elif hash microk8s 2>/dev/null; then
- KUBECTL_BIN='microk8s.kubectl'
- fi
+ for bin in kubectl kubectl.exe microk8s.kubectl; do
+ if type $bin &>/dev/null; then
+ KUBECTL_BIN="$bin"
+ break
+ fi
+ done
fi
-if ! hash "${KUBECTL_BIN}" 2>/dev/null; then
+if ! type "${KUBECTL_BIN}" &>/dev/null; then
echo >&2 "kubectl is not installed"
exit 1
fi |
Hi!
Script fails to find kubectl binary in case path hashing is disabled with
set +o hashall
orset +h
.The text was updated successfully, but these errors were encountered: