aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-09-09 21:49:12 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-09-09 21:49:12 +1200
commit899cb9446ed369efddae4303fe84e99a543bb8fe (patch)
treec25de5a8e45e26858194329ae209114d5ebb4dfd /bash
parentPreserve SSH_CLIENT as well as SSH_CONNECTION (diff)
downloaddotfiles-899cb9446ed369efddae4303fe84e99a543bb8fe.tar.gz
dotfiles-899cb9446ed369efddae4303fe84e99a543bb8fe.zip
Better syntax for array append
Diffstat (limited to 'bash')
-rw-r--r--bash/bashrc.d/cd.bash2
-rw-r--r--bash/bashrc.d/prompt.bash12
-rw-r--r--bash/bashrc.d/ssh.bash2
3 files changed, 8 insertions, 8 deletions
diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash
index f16aad41..6d7e2573 100644
--- a/bash/bashrc.d/cd.bash
+++ b/bash/bashrc.d/cd.bash
@@ -4,7 +4,7 @@ cd() {
local opt OPTIND=0
local -a opts
while getopts elP opt; do
- opts[${#opts[@]}]=-$opt
+ opts=("${opts[@]}" -"$opt")
done
shift $((OPTIND-1))
if (($# == 2)); then
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 0009fe94..6ecf44ba 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -72,24 +72,24 @@ prompt() {
# If there are staged changes in the working tree, add a plus sign
# to the state
if ! git diff --quiet --ignore-submodules --cached; then
- state[${#state[@]}]='+'
+ state=("${state[@]}" '+')
fi
# If there are any modified tracked files in the working tree, add
# an exclamation mark to the state
if ! git diff-files --quiet --ignore-submodules --; then
- state[${#state[@]}]='!'
+ state=("${state[@]}" '!')
fi
# If there are any stashed changes, add a circumflex to the state
if git rev-parse --verify refs/stash >/dev/null 2>&1; then
- state[${#state[@]}]='^'
+ state=("${state[@]}" '^')
fi
# If there are any new unignored files in the working tree, add a
# question mark to the state
if [[ $(git ls-files --others --exclude-standard) ]]; then
- state[${#state[@]}]='?'
+ state=("${state[@]}" '?')
fi
# Print the status in brackets with a git: prefix
@@ -111,7 +111,7 @@ prompt() {
# If there are changes in the tree, add an exclamation mark to the
# state
if [[ $(hg status 2>/dev/null) ]]; then
- state[${#state[@]}]='!'
+ state=("${state[@]}" '!')
fi
# Print the status in brackets with an hg: prefix
@@ -146,7 +146,7 @@ prompt() {
# If there are changes in the working directory, add an exclamation
# mark to the state
if [[ $(svn status 2>/dev/null) ]]; then
- state[${#state[@]}]='!'
+ state=("${state[@]}" '!')
fi
# Print the state in brackets with an svn: prefix
diff --git a/bash/bashrc.d/ssh.bash b/bash/bashrc.d/ssh.bash
index 93aeecbd..9ac90b7d 100644
--- a/bash/bashrc.d/ssh.bash
+++ b/bash/bashrc.d/ssh.bash
@@ -13,7 +13,7 @@ _ssh() {
local option value
while read -r option value _; do
if [[ $option == Host && $value != *'*'* ]]; then
- hosts[${#hosts[@]}]=$value
+ hosts=("${hosts[@]}" "$value")
fi
done < "$config"