From 65a7822e920e16744a9009eafe1a5f8182ff8dd5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 11 Dec 2015 14:22:31 +1300 Subject: Put printing/globbing in subshell --- bash/bashrc.d/keep.bash | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'bash/bashrc.d') 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 -- cgit v1.2.3