aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-12-11 16:36:13 +1300
committerTom Ryder <tom@sanctum.geek.nz>2013-12-11 16:36:13 +1300
commit03a5e3c175c0facf52c4d588745d58daa3265a52 (patch)
treec66e0f6abb27797d367ea92b179a0429bfae8cdb /bash/bashrc.d
parentGot my logic backwards; UNSET options (diff)
downloaddotfiles-03a5e3c175c0facf52c4d588745d58daa3265a52.tar.gz
dotfiles-03a5e3c175c0facf52c4d588745d58daa3265a52.zip
Better error conditions
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/cf.bash12
1 files changed, 11 insertions, 1 deletions
diff --git a/bash/bashrc.d/cf.bash b/bash/bashrc.d/cf.bash
index 17c84ade..cb06aa56 100644
--- a/bash/bashrc.d/cf.bash
+++ b/bash/bashrc.d/cf.bash
@@ -5,10 +5,20 @@ cf() {
# Specify directory to check
dir=${1:-$PWD}
- if [[ ! -d $dir ]]; then
+
+ # Error conditions
+ if [[ ! -e $dir ]]; then
+ printf 'bash: cf: %s does not exist\n' \
+ "$dir" >&2
+ return 1
+ elif [[ ! -d $dir ]]; then
printf 'bash: cf: %s is not a directory\n' \
"$dir" >&2
return 1
+ elif [[ ! -r $dir ]]; then
+ printf 'bash: cf: %s is not readable\n' \
+ "$dir" >&2
+ return 1
fi
# Record current state of dotglob and nullglob