diff options
Diffstat (limited to 'bash/bashrc.d/cf.bash')
-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"/*) |