Removed usage of += as it’s unsupported on bash versions < 3.1.

pull/945/head
Andrew Miller 2017-04-24 15:55:48 +09:00
parent eb9a1eaa83
commit 54b8e1635e
12 changed files with 48 additions and 48 deletions

View File

@ -534,12 +534,12 @@ _docker_compose() {
case "${words[$counter]}" in
$(__docker_compose_to_extglob "$daemon_boolean_options") )
local opt=${words[counter]}
daemon_options+=($opt)
daemon_options=(${daemon_options[@]} $opt)
;;
$(__docker_compose_to_extglob "$daemon_options_with_args") )
local opt=${words[counter]}
local arg=${words[++counter]}
daemon_options+=($opt $arg)
daemon_options=(${daemon_options[@]} $opt $arg)
;;
-*)
;;

View File

@ -147,7 +147,7 @@ __docker_complete_containers_and_images() {
__docker_complete_containers_all
local containers=( "${COMPREPLY[@]}" )
__docker_complete_images
COMPREPLY+=( "${containers[@]}" )
COMPREPLY=( "${COMPREPLY[@]}" "${containers[@]}" )
}
# Returns the names and optionally IDs of networks.
@ -235,7 +235,7 @@ __docker_complete_nodes() {
__docker_complete_nodes_plus_self() {
__docker_complete_nodes "$@"
COMPREPLY+=( self )
COMPREPLY=( ${COMPREPLY[@]} self )
}
# Returns a list of all services. Additional arguments to `docker service ls`
@ -2375,7 +2375,7 @@ _docker_run() {
seccomp)
local cur=${cur##*=}
_filedir
COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) )
COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "unconfined" -- "$cur" ) )
return
;;
esac

View File

@ -86,7 +86,7 @@ _go()
0)
_filedir go
_go_importpath_cache
COMPREPLY+=(`_go_importpath "$cur"`)
COMPREPLY=(${COMPREPLY[@]} `_go_importpath "$cur"`)
;;
1)
_filedir go

View File

@ -49,7 +49,7 @@ function alias_completion {
eval "$completion_loader $alias_cmd"
# 124 means completion loader was successful
[[ $? -eq 124 ]] || continue
completions+=($alias_cmd)
completions=(${completions[@]} $alias_cmd)
else
continue
fi

View File

@ -34,7 +34,7 @@ fi
# with the same name in project directories
for i in ${PROJECT_PATHS//:/$'\n'}; do
if [ -d "$i"/"$1" ]; then
dests+=("$i/$1")
dests=(${dests[@]} "$i/$1")
fi
done
@ -49,7 +49,7 @@ elif [ ${#dests[@]} -eq 1 ]; then
elif [ ${#dests[@]} -gt 1 ]; then
PS3="Multiple project directories found. Please select one: "
dests+=("cancel")
dests=(${dests[@]} "cancel")
select d in "${dests[@]}"; do
case $d in
"cancel")

View File

@ -149,7 +149,7 @@ function git_prompt_minimal_info {
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref}
# Get the status
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no'
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags="${git_status_flags} -untracked-files=no"
status=$(command git status ${git_status_flags} 2> /dev/null | tail -n1)
if [[ -n ${status} ]]; then
@ -208,15 +208,15 @@ function git_prompt_vars {
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
SCM_DIRTY=1
if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then
[[ "${staged_count}" -gt 0 ]] && details+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3
[[ "${unstaged_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2
[[ "${untracked_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1
[[ "${staged_count}" -gt 0 ]] && details="${details} ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3
[[ "${unstaged_count}" -gt 0 ]] && details="${details} ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2
[[ "${untracked_count}" -gt 0 ]] && details="${details} ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1
fi
SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
fi
fi
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)"
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details="${details}$(git_user_info)"
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
@ -237,15 +237,15 @@ function git_prompt_vars {
if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) ||
[[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then
remote_info="${remote_name}"
[[ "${same_branch_name}" != "true" ]] && remote_info+="/${remote_branch}"
[[ "${same_branch_name}" != "true" ]] && remote_info="${remote_info}/${remote_branch}"
elif [[ ${same_branch_name} != "true" ]]; then
remote_info="${remote_branch}"
fi
if [[ -n "${remote_info}" ]];then
if [[ "${branch_gone}" = "true" ]]; then
SCM_BRANCH+="${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}"
SCM_BRANCH="${SCM_BRANCH}${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}"
else
SCM_BRANCH+="${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}"
SCM_BRANCH="${SCM_BRANCH}${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}"
fi
fi
fi
@ -267,13 +267,13 @@ function git_prompt_vars {
local ahead_re='.+ahead ([0-9]+).+'
local behind_re='.+behind ([0-9]+).+'
[[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH="${SCM_BRANCH} ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}"
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH="${SCM_BRANCH} ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
local stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}"
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH="${SCM_BRANCH} {${stash_count}}"
SCM_BRANCH+=${details}
SCM_BRANCH="${SCM_BRANCH}${details}"
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}

View File

@ -13,13 +13,13 @@ ____brainy_top_left_parse() {
args=( $1 )
IFS="${ifs_old}"
if [ -n "${args[3]}" ]; then
_TOP_LEFT+="${args[2]}${args[3]}"
_TOP_LEFT="${_TOP_LEFT}${args[2]}${args[3]}"
fi
_TOP_LEFT+="${args[0]}${args[1]}"
_TOP_LEFT="${_TOP_LEFT}${args[0]}${args[1]}"
if [ -n "${args[4]}" ]; then
_TOP_LEFT+="${args[2]}${args[4]}"
_TOP_LEFT="${_TOP_LEFT}${args[2]}${args[4]}"
fi
_TOP_LEFT+=" "
_TOP_LEFT="${_TOP_LEFT} "
}
____brainy_top_right_parse() {
@ -27,13 +27,13 @@ ____brainy_top_right_parse() {
IFS="|"
args=( $1 )
IFS="${ifs_old}"
_TOP_RIGHT+=" "
_TOP_RIGHT="${_TOP_RIGHT} "
if [ -n "${args[3]}" ]; then
_TOP_RIGHT+="${args[2]}${args[3]}"
_TOP_RIGHT="${_TOP_RIGHT}${args[2]}${args[3]}"
fi
_TOP_RIGHT+="${args[0]}${args[1]}"
_TOP_RIGHT="${_TOP_RIGHT}${args[0]}${args[1]}"
if [ -n "${args[4]}" ]; then
_TOP_RIGHT+="${args[2]}${args[4]}"
_TOP_RIGHT="${_TOP_RIGHT}${args[2]}${args[4]}"
fi
__TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1 ))
(( __SEG_AT_RIGHT += 1 ))
@ -44,8 +44,8 @@ ____brainy_bottom_parse() {
IFS="|"
args=( $1 )
IFS="${ifs_old}"
_BOTTOM+="${args[0]}${args[1]}"
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
_BOTTOM="${_BOTTOM}${args[0]}${args[1]}"
[ ${#args[1]} -gt 0 ] && _BOTTOM="${_BOTTOM} "
}
____brainy_top() {
@ -60,7 +60,7 @@ ____brainy_top() {
done
___cursor_right="\033[500C"
_TOP_LEFT+="${___cursor_right}"
_TOP_LEFT="${_TOP_LEFT}${___cursor_right}"
for seg in ${___BRAINY_TOP_RIGHT}; do
info="$(___brainy_prompt_"${seg}")"
@ -69,7 +69,7 @@ ____brainy_top() {
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 1 ))
___cursor_adjust="\033[${__TOP_RIGHT_LEN}D"
_TOP_LEFT+="${___cursor_adjust}"
_TOP_LEFT="${_TOP_LEFT}${___cursor_adjust}"
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
}
@ -162,7 +162,7 @@ ___brainy_prompt_battery() {
color=$bold_red
fi
box="[|]"
ac_adapter_connected && info+="+"
ac_adapter_connected && info="${info}+"
[ "$info" == "100+" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}

View File

@ -18,7 +18,7 @@ function __powerline_right_segment {
separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})"
(( padding += 1 ))
fi
RIGHT_PROMPT+="${separator_color}${separator_char}${normal}$(set_color - ${params[1]}) ${params[0]} ${normal}$(set_color - ${COLOR})${normal}"
RIGHT_PROMPT="${RIGHT_PROMPT}${separator_color}${separator_char}${normal}$(set_color - ${params[1]}) ${params[0]} ${normal}$(set_color - ${COLOR})${normal}"
RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding ))
LAST_SEGMENT_COLOR="${params[1]}"
(( SEGMENTS_AT_RIGHT += 1 ))
@ -41,16 +41,16 @@ function __powerline_prompt_command {
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT="${LEFT_PROMPT}$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
## right prompt ##
if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then
LEFT_PROMPT+="${move_cursor_rightmost}"
LEFT_PROMPT="${LEFT_PROMPT}${move_cursor_rightmost}"
for segment in $POWERLINE_RIGHT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_right_segment "${info}"
done
LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D"
LEFT_PROMPT="${LEFT_PROMPT}\033[${RIGHT_PROMPT_LENGTH}D"
fi
PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} "

View File

@ -10,6 +10,6 @@ function __powerline_left_segment {
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="${separator_char}"
fi
LEFT_PROMPT+="${separator}$(set_color ${params[1]} -) ${params[0]} ${normal}"
LEFT_PROMPT="${LEFT_PROMPT}${separator}$(set_color ${params[1]} -) ${params[0]} ${normal}"
(( SEGMENTS_AT_LEFT += 1 ))
}

View File

@ -5,7 +5,7 @@ function __powerline_left_segment {
local params=( $1 )
IFS="${OLD_IFS}"
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LEFT_PROMPT="${LEFT_PROMPT}${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]}
}
@ -20,7 +20,7 @@ function __powerline_prompt_command {
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}"
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT="${LEFT_PROMPT}$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}"
PS1="${LEFT_PROMPT} "

View File

@ -83,7 +83,7 @@ function __powerline_scm_prompt {
color=${SCM_THEME_PROMPT_CLEAN_COLOR}
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
scm_prompt="${scm_prompt}${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt}${scm}|${color}"
fi
@ -132,7 +132,7 @@ function __powerline_left_segment {
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}"
fi
LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LEFT_PROMPT="${LEFT_PROMPT}${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}"
LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 ))
}
@ -155,7 +155,7 @@ function __powerline_prompt_command {
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT="${LEFT_PROMPT}$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${normal}"
PS1="${LEFT_PROMPT} "

View File

@ -138,22 +138,22 @@ prompt_git() {
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
s=${s}'+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
s=${s}'!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
s=${s}'?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
s=${s}'$';
fi;
fi;