diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-12-11 16:06:51 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-12-11 16:06:51 +1300 |
commit | 0f527bd7c2aa4a7b81ea6f29fe8ab0ed538b0859 (patch) | |
tree | 71f92ebdb29cf78240a56a74573300e416fb2e93 /bash/bashrc.d | |
parent | Simpler output in the style of du(1) (diff) | |
download | dotfiles-0f527bd7c2aa4a7b81ea6f29fe8ab0ed538b0859.tar.gz dotfiles-0f527bd7c2aa4a7b81ea6f29fe8ab0ed538b0859.zip |
Error message if not a directory
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r-- | bash/bashrc.d/cf.bash | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bash/bashrc.d/cf.bash b/bash/bashrc.d/cf.bash index e336478c..a376b089 100644 --- a/bash/bashrc.d/cf.bash +++ b/bash/bashrc.d/cf.bash @@ -3,13 +3,18 @@ cf() { local dir dgs ngs local -a files + # Specify directory to check + dir=${1:-$PWD} + if [[ ! -d $dir ]]; then + printf 'bash: cf: %s is not a directory\n' \ + "$dir" >&2 + return 1 + fi + # Record current state of dotglob and nullglob shopt -pq dotglob && dgs=1 shopt -pq nullglob && ngs=1 - # Specify directory to check - dir=${1:-$PWD} - # Retrieve the files array shopt -s dotglob nullglob files=("$dir"/*) |