diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-12-11 16:36:13 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-12-11 16:36:13 +1300 |
commit | 03a5e3c175c0facf52c4d588745d58daa3265a52 (patch) | |
tree | c66e0f6abb27797d367ea92b179a0429bfae8cdb /bash/bashrc.d | |
parent | Got my logic backwards; UNSET options (diff) | |
download | dotfiles-03a5e3c175c0facf52c4d588745d58daa3265a52.tar.gz dotfiles-03a5e3c175c0facf52c4d588745d58daa3265a52.zip |
Better error conditions
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r-- | bash/bashrc.d/cf.bash | 12 |
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 |