diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-12-11 14:22:31 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-12-11 14:22:31 +1300 |
commit | 65a7822e920e16744a9009eafe1a5f8182ff8dd5 (patch) | |
tree | b7819d6b236c9fb7f8a0f4a8395765851682968e /bash | |
parent | Create bashkeep directory if it doesn't exist (diff) | |
download | dotfiles-65a7822e920e16744a9009eafe1a5f8182ff8dd5.tar.gz dotfiles-65a7822e920e16744a9009eafe1a5f8182ff8dd5.zip |
Put printing/globbing in subshell
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/keep.bash | 14 |
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 |