aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-04 12:55:18 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-04 12:55:18 +1200
commitf06a44231a91ba3561c9492c1e31b1c30c165130 (patch)
treefd1f2f72a65ae56c5dc0c4a07319c292d8433a5c
parentCorrect argument test in bd() and prompt() (diff)
downloaddotfiles-f06a44231a91ba3561c9492c1e31b1c30c165130.tar.gz
dotfiles-f06a44231a91ba3561c9492c1e31b1c30c165130.zip
Use consistent [[ syntax
Explicit -n, ! within [[
-rw-r--r--bash/bashrc.d/bd.bash2
-rw-r--r--bash/bashrc.d/grep.bash2
-rw-r--r--bash/bashrc.d/keychain.bash2
-rw-r--r--bash/bashrc.d/ls.bash2
-rw-r--r--bash/bashrc.d/pd.bash2
-rw-r--r--bash/bashrc.d/prompt.bash4
-rw-r--r--bash/bashrc.d/vr.bash12
7 files changed, 13 insertions, 13 deletions
diff --git a/bash/bashrc.d/bd.bash b/bash/bashrc.d/bd.bash
index 73e98299..1c326c88 100644
--- a/bash/bashrc.d/bd.bash
+++ b/bash/bashrc.d/bd.bash
@@ -25,7 +25,7 @@ _bd() {
# Build a list of dirs in $PWD
local -a dirs
while read -d / -r dir ; do
- if [[ $dir ]] ; then
+ if [[ -n $dir ]] ; then
dirs=("${dirs[@]}" "$dir")
fi
done < <(printf %s "$PWD")
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash
index 12354d78..52570ea2 100644
--- a/bash/bashrc.d/grep.bash
+++ b/bash/bashrc.d/grep.bash
@@ -1,6 +1,6 @@
# Define function wrapper for grep(1) with --color option if GREP_COLORS is
# set; checks that color is available in the terminal within the function
-if ! [[ $GREP_COLORS ]] ; then
+if [[ ! -n $GREP_COLORS ]] ; then
return
fi
diff --git a/bash/bashrc.d/keychain.bash b/bash/bashrc.d/keychain.bash
index eae40bbc..a8585b6b 100644
--- a/bash/bashrc.d/keychain.bash
+++ b/bash/bashrc.d/keychain.bash
@@ -1,5 +1,5 @@
# If GPG_TTY is set, update it
-if [[ $GPG_TTY ]] ; then
+if [[ -n $GPG_TTY ]] ; then
GPG_TTY=$(tty)
fi
diff --git a/bash/bashrc.d/ls.bash b/bash/bashrc.d/ls.bash
index c47859c9..96593e33 100644
--- a/bash/bashrc.d/ls.bash
+++ b/bash/bashrc.d/ls.bash
@@ -1,6 +1,6 @@
# Define function wrapper for ls(1) with --color option if LS_COLORS is set;
# checks that color is available in the terminal within the function
-if ! [[ $LS_COLORS ]] ; then
+if [[ ! -n $LS_COLORS ]] ; then
return
fi
diff --git a/bash/bashrc.d/pd.bash b/bash/bashrc.d/pd.bash
index 2547c3f0..be42403b 100644
--- a/bash/bashrc.d/pd.bash
+++ b/bash/bashrc.d/pd.bash
@@ -36,7 +36,7 @@ pd() {
return 2
;;
esac
- if [[ $target ]] ; then
+ if [[ -n $target ]] ; then
builtin cd "${opts[@]}" -- "$target"
else
printf 'bash: %s: error calculating parent directory\n' \
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 9ade2c80..27cb9dd5 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -86,7 +86,7 @@ prompt() {
git symbolic-ref --quiet HEAD \
|| git rev-parse --short HEAD
} 2>/dev/null )
- if [[ ! $branch ]] ; then
+ if [[ ! -n $branch ]] ; then
return 1
fi
branch=${branch##*/}
@@ -190,7 +190,7 @@ prompt() {
done < <(svn info 2>/dev/null)
# Exit if we couldn't get either
- if ! [[ $url && $root ]] ; then
+ if [[ ! -n $url || ! -n $root ]] ; then
return 1
fi
diff --git a/bash/bashrc.d/vr.bash b/bash/bashrc.d/vr.bash
index 150861a8..fc1de5ef 100644
--- a/bash/bashrc.d/vr.bash
+++ b/bash/bashrc.d/vr.bash
@@ -4,17 +4,17 @@ vr() {
path=${path%/}
# Raise some helpful errors
- if ! [[ -e $path ]] ; then
+ if [[ ! -e $path ]] ; then
printf 'bash: %s: %s: No such file or directory\n' \
"$FUNCNAME" "$path"
return 1
fi
- if ! [[ -d $path ]] ; then
+ if [[ ! -d $path ]] ; then
printf 'bash: %s: %s: Not a directory\n' \
"$FUNCNAME" "$path"
return 1
fi
- if ! [[ -x $path ]] ; then
+ if [[ ! -x $path ]] ; then
printf 'bash: %s: %s: Permission denied\n' \
"$FUNCNAME" "$path"
return 1
@@ -22,14 +22,14 @@ vr() {
# Ask Git the top level
local git_root=$(cd -- "$path" && git rev-parse --show-toplevel 2>/dev/null)
- if [[ $git_root ]] ; then
+ if [[ -n $git_root ]] ; then
cd -- "$git_root"
return
fi
# Ask Mercurial the top level
local hg_root=$(cd -- "$path" && hg root 2>/dev/null)
- if [[ $hg_root ]] ; then
+ if [[ -n $hg_root ]] ; then
cd -- "$hg_root"
return
fi
@@ -38,7 +38,7 @@ vr() {
# doesn't; hopefully that's the root
if [[ -d $path/.svn ]] ; then
local search=$path
- while [[ $search ]] ; do
+ while [[ -n $search ]] ; do
if [[ -d ${search%/*}/.svn ]] ; then
search=${search%/*}
else