fix globbing problem in _find function
parent
22b3c0cc36
commit
28bce82117
|
@ -1 +1,2 @@
|
|||
*/archive/*
|
||||
/ssh/config/_config
|
||||
|
|
|
@ -58,7 +58,7 @@ build_file "/etc/ssh/ssh_config" $OUTPUT
|
|||
for CDIR in "${CDIRS[@]}"
|
||||
do
|
||||
# FILES=$(find -n '*.cfg' -d 0 $CDIR)
|
||||
for f in $(find -n '*.cfg' -p 'archive off' -d 0 $CDIR) ;
|
||||
for f in $(_find -n '*.cfg' -p 'archive off' -d 0 $CDIR) ;
|
||||
do
|
||||
# echo "Processing $f";
|
||||
[[ $f ]] && build_file "$f" $OUTPUT
|
||||
|
|
|
@ -71,7 +71,7 @@ case "$OPTION" in
|
|||
n)
|
||||
# NAMES=("$OPTARG")
|
||||
IFS=',' read -r -a NAMES <<< "${OPTARG}"
|
||||
# echo INCLUDING ONLY THESE FILE NAMES ${NAMES[*]}
|
||||
# NAMES=$OPTARG
|
||||
;;
|
||||
d)
|
||||
DEPTH=$OPTARG
|
||||
|
@ -128,6 +128,8 @@ fi
|
|||
# echo paths ${PATHS[@]} >&2
|
||||
# echo exclude names ${ENAMES[@]} >&2
|
||||
|
||||
set -o noglob
|
||||
|
||||
if [[ ${PATHS[0]} ]]; then
|
||||
for path in ${PATHS[@]}; do
|
||||
# echo excluding $path
|
||||
|
@ -137,22 +139,32 @@ fi
|
|||
|
||||
if [[ ${ENAMES[0]} ]]; then
|
||||
for name in ${ENAMES[@]}; do
|
||||
# echo excluding name $name
|
||||
FIND+=$(echo ' ! -name "'${name}'"')
|
||||
debug excluding name "$name"
|
||||
FIND+=$(echo ' ! -name '$name'')
|
||||
done
|
||||
fi
|
||||
|
||||
debug "INCLUDING ONLY THESE FILE NAMES ${NAMES[*]}"
|
||||
if [[ ${NAMES[0]} ]]; then
|
||||
for name in ${NAMES[@]}; do
|
||||
# echo only finding $name
|
||||
FIND+=$(echo " -name ${name}")
|
||||
for name in "${NAMES[@]}"; do
|
||||
debug only finding $name
|
||||
FIND+=$(echo " -name '${name}'")
|
||||
done
|
||||
fi
|
||||
|
||||
# if [[ $NAMES ]]; then
|
||||
# debug names for find command $NAMES
|
||||
# for name in $NAMES; do
|
||||
# debug "xxonly finding '$name'"
|
||||
# FIND+=$(set -o noglob;echo " -name '${name}'")
|
||||
# done
|
||||
# fi
|
||||
|
||||
|
||||
# echo
|
||||
# echo find dir: $DIR >&2
|
||||
debug "find command: $FIND"
|
||||
|
||||
set +o noglob
|
||||
local FILES
|
||||
FILES=$(eval $FIND | sort)
|
||||
[[ $FILES ]] && echo $FILES
|
||||
|
|
Reference in New Issue