lib/theme: fix SC2155, SC2154, SC2034

pull/1947/head
John D Pell 2021-09-17 22:25:53 -07:00
parent 4af7e9abd0
commit 94c2ea60cc
1 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,5 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
CLOCK_CHAR_THEME_PROMPT_PREFIX='' CLOCK_CHAR_THEME_PROMPT_PREFIX=''
CLOCK_CHAR_THEME_PROMPT_SUFFIX='' CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
@ -122,12 +123,11 @@ function scm {
} }
scm_prompt() { scm_prompt() {
local CHAR=$(scm_char) local CHAR
CHAR="$(scm_char)"
local format=${SCM_PROMPT_FORMAT:-'[%s%s]'} local format=${SCM_PROMPT_FORMAT:-'[%s%s]'}
if [[ $CHAR = "$SCM_NONE_CHAR" ]]; then if [[ "${CHAR}" != "$SCM_NONE_CHAR" ]]; then
return
else
# shellcheck disable=2059 # shellcheck disable=2059
printf "$format\n" "$CHAR" "$(scm_prompt_info)" printf "$format\n" "$CHAR" "$(scm_prompt_info)"
fi fi
@ -344,15 +344,15 @@ function svn_prompt_vars {
# - .hg is located in ~/Projects/Foo/.hg # - .hg is located in ~/Projects/Foo/.hg
# - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo # - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo
function get_hg_root { function get_hg_root {
local CURRENT_DIR=$(pwd) local CURRENT_DIR="${PWD}"
while [ "$CURRENT_DIR" != "/" ]; do while [[ "${CURRENT_DIR:-/}" != "/" ]]; do
if [ -d "$CURRENT_DIR/.hg" ]; then if [[ -d "$CURRENT_DIR/.hg" ]]; then
echo "$CURRENT_DIR/.hg" echo "$CURRENT_DIR/.hg"
return return
fi fi
CURRENT_DIR=$(dirname "$CURRENT_DIR") CURRENT_DIR="${CURRENT_DIR%/*}"
done done
} }
@ -544,7 +544,7 @@ function prompt_char {
function battery_char { function battery_char {
if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then
echo -e "${bold_red}$(battery_percentage)%" echo -e "${bold_red:-}$(battery_percentage)%"
fi fi
} }
@ -586,7 +586,7 @@ function __check_precmd_conflict() {
function safe_append_prompt_command { function safe_append_prompt_command {
local prompt_re local prompt_re
if [ "${__bp_imported}" == "defined" ]; then if [ "${__bp_imported:-missing}" == "defined" ]; then
# We are using bash-preexec # We are using bash-preexec
if ! __check_precmd_conflict "${1}"; then if ! __check_precmd_conflict "${1}"; then
precmd_functions+=("${1}") precmd_functions+=("${1}")
@ -601,7 +601,7 @@ function safe_append_prompt_command {
prompt_re="\<${1}\>" prompt_re="\<${1}\>"
fi fi
if [[ ${PROMPT_COMMAND} =~ ${prompt_re} ]]; then if [[ ${PROMPT_COMMAND[*]:-} =~ ${prompt_re} ]]; then
return return
elif [[ -z ${PROMPT_COMMAND} ]]; then elif [[ -z ${PROMPT_COMMAND} ]]; then
PROMPT_COMMAND="${1}" PROMPT_COMMAND="${1}"