aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-12-11 14:22:31 +1300
committerTom Ryder <tom@sanctum.geek.nz>2015-12-11 14:22:31 +1300
commit65a7822e920e16744a9009eafe1a5f8182ff8dd5 (patch)
treeb7819d6b236c9fb7f8a0f4a8395765851682968e /bash/bashrc.d
parentCreate bashkeep directory if it doesn't exist (diff)
downloaddotfiles-65a7822e920e16744a9009eafe1a5f8182ff8dd5.tar.gz
dotfiles-65a7822e920e16744a9009eafe1a5f8182ff8dd5.zip
Put printing/globbing in subshell
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/keep.bash14
1 files changed, 9 insertions, 5 deletions
diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash
index 6295069d..c71a80a9 100644
--- a/bash/bashrc.d/keep.bash
+++ b/bash/bashrc.d/keep.bash
@@ -114,11 +114,15 @@ EOF
fi
# Otherwise the user must want us to print all the NAMEs kept
- local -a keeps
- keeps=("${bashkeep}"/*.bash)
- keeps=("${keeps[@]##*/}")
- keeps=("${keeps[@]%.bash}")
- printf '%s\n' "${keeps[@]}"
+ (
+ shopt -s dotglob nullglob
+ declare -a keeps
+ keeps=("${bashkeep}"/*.bash)
+ keeps=("${keeps[@]##*/}")
+ keeps=("${keeps[@]%.bash}")
+ ((${keeps[@]})) || exit 0
+ printf '%s\n' "${keeps[@]}"
+ )
}
# Complete calls to keep with existing function names and variable names