diff --git a/configs/git.sh b/configs/git.sh index 3c7e6d2..db51b60 100644 --- a/configs/git.sh +++ b/configs/git.sh @@ -59,6 +59,7 @@ if bacon_defined BACON_PROMPT_PS1_LAYOUT && bacon_definedf bacon_promptc; then brch="${brchi[1]//..*/}" # check whether the local repo is different from remote tracked repo [[ -n ${brchi[2]} && ${brchi[*]:2} =~ '[' ]] && brch+="${trki[${brchi[2]#[}]}${brchi[3]%]}" + local c local tmp=() for c in "${bstat[@]:1}"; do # prevent special chars to be expand diff --git a/configs/pip.sh b/configs/pip.sh index 20c3b34..3c101bb 100644 --- a/configs/pip.sh +++ b/configs/pip.sh @@ -7,6 +7,7 @@ hash pip &>/dev/null || return 1 bacon_export pip pip_upgrade() { + local pkg for pkg in $(pip list --outdate --format legacy | awk '{print $1}'); do sudo pip install --upgrade "${pkg}" done diff --git a/lib/bacon-async.sh b/lib/bacon-async.sh index 3242046..bcab5c5 100644 --- a/lib/bacon-async.sh +++ b/lib/bacon-async.sh @@ -42,6 +42,7 @@ bacon_async_add() { bacon_async_del() { [[ $# == 1 ]] || return 1 local jobs=() + local j [[ $# == 0 ]] && jobs=("${!BACON_ASYNC_RUN[@]}") || jobs=("$@") for j in "${jobs[@]}"; do [[ -n $j && -n ${BACON_ASYNC_RUN[$j]} ]] && unset BACON_ASYNC_RUN["$j"] @@ -81,6 +82,7 @@ bacon_async_run() { bacon_async_start() { [[ -n $BACON_ASYNC_MQ ]] || bacon_async_mq_init || return 1 local jobs=() + local j [[ $# == 0 ]] && jobs=("${!BACON_ASYNC_RUN[@]}") || jobs=("$@") for j in "${jobs[@]}"; do if [[ -n ${BACON_ASYNC_RUN[$j]} ]]; then @@ -91,6 +93,7 @@ bacon_async_start() { bacon_async_stop() { local jobs=() + local j [[ $# == 0 ]] && jobs=("${!BACON_ASYNC_JQ[@]}") || jobs=("$@") for j in "${jobs[@]}"; do if [[ -n ${BACON_ASYNC_JQ[$j]} ]] && bacon_is_running "${BACON_ASYNC_JQ[$j]}"; then @@ -102,6 +105,7 @@ bacon_async_stop() { bacon_async_wait() { local pids=() runs=() + local p [[ $# == 0 ]] && pids=("${BACON_ASYNC_JQ[@]}") || pids=("$@") for p in "${pids[@]}"; do [[ -n $p && $p =~ [0-9]+ ]] && bacon_is_running "$p" && runs+=("$p") diff --git a/lib/bacon-main.sh b/lib/bacon-main.sh index f638c39..bb7bc68 100644 --- a/lib/bacon-main.sh +++ b/lib/bacon-main.sh @@ -9,6 +9,7 @@ export BACON_MAIN_ABS_DIR="$(dirname "$BACON_MAIN_ABS_SRC")" bacon_init() { local BACON_LIB_DIR=("$BACON_MAIN_ABS_DIR") + local c for c in "$@"; do bacon_load "${c}.sh" || true done diff --git a/lib/bacon-precmd.sh b/lib/bacon-precmd.sh index a2cf32d..ead6a87 100644 --- a/lib/bacon-precmd.sh +++ b/lib/bacon-precmd.sh @@ -9,6 +9,7 @@ declare -ga BACON_PRECMD_TRAP=() declare -g BACON_PRECMD_TRAP_SIG="${BACON_PRECMD_TRAP_SIG:-}" bacon_precmd_handler() { + local cmd for cmd in "${BACON_PRECMD_TRAP[@]}"; do eval "$cmd" done diff --git a/lib/bacon-prompt.sh b/lib/bacon-prompt.sh index 391307f..cd73f31 100644 --- a/lib/bacon-prompt.sh +++ b/lib/bacon-prompt.sh @@ -36,7 +36,7 @@ bacon_prompt_location() { bacon_prompt_counter() { local -A counters - local str='' + local str='' cnt for cnt in "${BACON_PROMPT_COUNTERS[@]}"; do # shellcheck disable=SC2155 local nr="$(eval "$cnt")" @@ -57,7 +57,7 @@ bacon_prompt_dollar() { } bacon_prompt_ps1() { - ps1= + local ps1 layout for layout in "${BACON_PROMPT_PS1_LAYOUT[@]}"; do bacon_definedf "$layout" && ps1+="$($layout)" done diff --git a/lib/bacon-utils.sh b/lib/bacon-utils.sh index 1b92a53..a88f285 100644 --- a/lib/bacon-utils.sh +++ b/lib/bacon-utils.sh @@ -20,6 +20,7 @@ bacon_has_map() { # Assigns the selected set of escape mappings to the given associative array names. bacon_color_init() { local -a fg_clrs bg_clrs msc + local x fg_clrs=(black red green yellow blue magenta cyan grey darkgrey ltred ltgreen ltyellow ltblue ltmagenta ltcyan white) bg_clrs=($(IFS=,; eval "echo bg_{${fg_clrs[*]}}")) msc=(sgr0 bold dim smul blink rev invis) @@ -53,7 +54,7 @@ bacon_color_init() { bacon_color_init --setaf BACON_COLOR --setab BACON_COLOR --misc BACON_COLOR bacon_set_color() { - local color + local color c for c in "$@"; do bacon_has_map BACON_COLOR "$c" && color+="${BACON_COLOR[$c]}" done @@ -255,7 +256,7 @@ bacon_popts() { shift 4 local -a soa=() loa=() local -A som=() lom=() - local sos los tmp m n + local sos los tmp o m n # construct optstrings for o in "${!__optstr[@]}"; do @@ -311,6 +312,7 @@ bacon_require_base() { local cmd="$1" local msg="$2" shift 2 + local obj for obj in "$@"; do "$cmd" "$obj" || miss+=("$obj") done @@ -417,6 +419,7 @@ bacon_filter() { local -n __array="$1" local p="$2" shift 2 + local arg for arg in "$@"; do [[ $arg =~ $p ]] && __array+=("$arg") || true done @@ -431,6 +434,7 @@ bacon_map() { local -n __array="$1" local func="$2" shift 2 + local i __array+=("$@") for i in "${__array[@]}"; do "$func" "__array[$i]"