Skip to content
Permalink
Browse files

Detect invocation style only in usage() (#183)

- removes global SELF variable
- fixes #181

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
  • Loading branch information
ahmetb committed Nov 11, 2019
1 parent dcb43fd commit 56e30d2b4371519b9c573229b711fe8820be080b
Showing with 12 additions and 8 deletions.
  1. +6 −4 kubectx
  2. +6 −4 kubens
10 kubectx
@@ -22,14 +22,16 @@ set -eou pipefail
IFS=$'\n\t'

SELF_CMD="$0"
SELF="kubectx"
if [[ "$(basename "$0")" == kubectl-* ]]; then # invoked as plugin
SELF="kubectl ctx"
fi

KUBECTX="${XDG_CACHE_HOME:-$HOME/.kube}/kubectx"

usage() {
local SELF
SELF="kubectx"
if [[ "$(basename "$0")" == kubectl-* ]]; then # invoked as plugin
SELF="kubectl ctx"
fi

cat <<EOF
USAGE:
$SELF : list the contexts
10 kubens
@@ -22,14 +22,16 @@ set -eou pipefail
IFS=$'\n\t'

SELF_CMD="$0"
SELF="kubens"
if [[ "$(basename "$0")" == kubectl-* ]]; then # invoked as plugin
SELF="kubectl ns"
fi

KUBENS_DIR="${XDG_CACHE_HOME:-$HOME/.kube}/kubens"

usage() {
local SELF
SELF="kubens"
if [[ "$(basename "$0")" == kubectl-* ]]; then # invoked as plugin
SELF="kubectl ns"
fi

cat <<EOF
USAGE:
$SELF : list the namespaces in the current context

0 comments on commit 56e30d2

Please sign in to comment.
You can’t perform that action at this time.