Skip to content

Commit a6342b5

Browse files
committed
lib/theme: Fix a *few* SC2154
These variables are referenced by themes already linted.
1 parent dbb3ea4 commit a6342b5

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

themes/base.theme.bash

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ RBFU_THEME_PROMPT_SUFFIX='|'
9292
: "${SVN_EXE:=$SCM_SVN}"
9393

9494
function _bash_it_appearance_scm_init() {
95-
GIT_EXE="$(type -P $SCM_GIT || true)"
96-
P4_EXE="$(type -P $SCM_P4 || true)"
97-
HG_EXE="$(type -P $SCM_HG || true)"
98-
SVN_EXE="$(type -P $SCM_SVN || true)"
95+
GIT_EXE="$(type -P "$SCM_GIT" || true)"
96+
P4_EXE="$(type -P "$SCM_P4" || true)"
97+
HG_EXE="$(type -P "$SCM_HG" || true)"
98+
SVN_EXE="$(type -P "$SCM_SVN" || true)"
9999

100100
# Check for broken SVN exe that is caused by some versions of Xcode.
101101
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
@@ -233,7 +233,7 @@ function git_prompt_minimal_info {
233233
}
234234

235235
function git_prompt_vars {
236-
if ${SCM_GIT_USE_GITSTATUS} && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT}" == "ok-sync" ]]; then
236+
if "${SCM_GIT_USE_GITSTATUS:-false}" && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT:-}" == "ok-sync" ]]; then
237237
# we can use faster gitstatus
238238
# use this variable in githelpers and below to choose gitstatus output
239239
SCM_GIT_GITSTATUS_RAN=true
@@ -257,8 +257,8 @@ function git_prompt_vars {
257257
fi
258258

259259
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
260-
commits_behind=${VCS_STATUS_COMMITS_BEHIND}
261-
commits_ahead=${VCS_STATUS_COMMITS_AHEAD}
260+
commits_behind=${VCS_STATUS_COMMITS_BEHIND?}
261+
commits_ahead=${VCS_STATUS_COMMITS_AHEAD?}
262262
else
263263
IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)"
264264
fi
@@ -274,7 +274,7 @@ function git_prompt_vars {
274274
if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then
275275
local stash_count
276276
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
277-
stash_count=${VCS_STATUS_STASHES}
277+
stash_count=${VCS_STATUS_STASHES?}
278278
else
279279
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
280280
fi
@@ -284,9 +284,9 @@ function git_prompt_vars {
284284
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
285285
if ! _git-hide-status; then
286286
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
287-
untracked_count=${VCS_STATUS_NUM_UNTRACKED}
288-
unstaged_count=${VCS_STATUS_NUM_UNSTAGED}
289-
staged_count=${VCS_STATUS_NUM_STAGED}
287+
untracked_count=${VCS_STATUS_NUM_UNTRACKED?}
288+
unstaged_count=${VCS_STATUS_NUM_UNSTAGED?}
289+
staged_count=${VCS_STATUS_NUM_STAGED?}
290290
else
291291
IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$(_git-status-counts)"
292292
fi
@@ -427,7 +427,7 @@ function rbenv_version_prompt {
427427
}
428428

429429
function rbfu_version_prompt {
430-
if [[ $RBFU_RUBY_VERSION ]]; then
430+
if [[ -n "${RBFU_RUBY_VERSION:-}" ]]; then
431431
echo -e "${RBFU_THEME_PROMPT_PREFIX}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX}"
432432
fi
433433
}
@@ -443,12 +443,12 @@ function chruby_version_prompt {
443443
if ! chruby | grep -q '\*'; then
444444
ruby_version="${ruby_version} (system)"
445445
fi
446-
echo -e "${CHRUBY_THEME_PROMPT_PREFIX}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX}"
446+
echo -e "${CHRUBY_THEME_PROMPT_PREFIX:-}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX:-}"
447447
fi
448448
}
449449

450450
function ruby_version_prompt {
451-
if [[ "${THEME_SHOW_RUBY_PROMPT}" = "true" ]]; then
451+
if [[ "${THEME_SHOW_RUBY_PROMPT:-}" == "true" ]]; then
452452
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
453453
fi
454454
}
@@ -462,21 +462,22 @@ function k8s_namespace_prompt {
462462
}
463463

464464
function virtualenv_prompt {
465-
if [[ -n "$VIRTUAL_ENV" ]]; then
466-
virtualenv=$(basename "$VIRTUAL_ENV")
465+
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
466+
virtualenv="${VIRTUAL_ENV##*/}"
467467
echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX"
468468
fi
469469
}
470470

471471
function condaenv_prompt {
472-
if [[ $CONDA_DEFAULT_ENV ]]; then
473-
echo -e "${CONDAENV_THEME_PROMPT_PREFIX}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX}"
472+
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then
473+
echo -e "${CONDAENV_THEME_PROMPT_PREFIX:-}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX:-}"
474474
fi
475475
}
476476

477477
function py_interp_prompt {
478+
local py_version
478479
py_version=$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}') || return
479-
echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}"
480+
echo -e "${PYTHON_THEME_PROMPT_PREFIX:-}${py_version}${PYTHON_THEME_PROMPT_SUFFIX:-}"
480481
}
481482

482483
function python_version_prompt {
@@ -504,7 +505,7 @@ function clock_char {
504505
function clock_prompt {
505506
CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"}
506507
CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"}
507-
[ -z "$THEME_SHOW_CLOCK" ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"}
508+
[[ -z "${THEME_SHOW_CLOCK:-}" ]] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"}
508509
SHOW_CLOCK=$THEME_SHOW_CLOCK
509510

510511
if [[ "${SHOW_CLOCK}" = "true" ]]; then
@@ -574,7 +575,7 @@ if ! _command_exists battery_percentage; then
574575
fi
575576

576577
function aws_profile {
577-
if [[ $AWS_DEFAULT_PROFILE ]]; then
578+
if [[ -n "${AWS_DEFAULT_PROFILE:-}" ]]; then
578579
echo -e "${AWS_DEFAULT_PROFILE}"
579580
else
580581
echo -e "default"

0 commit comments

Comments
 (0)