On Mon, May 30, 2022, at 2:42 PM, goncholden wrote:
> I do not know the details on code injection. Am using a function that
> searches for a phrase using grep.
>
> local progl=( "\*.{rc,.el,c,f}" )
> local pextd=( "${progl[@]}" "\*.{cp,cpp,f90,f95,f03,f08}" )
>
> local inclsf=()
> for el in "${incl[@]}" ; do
> case $el in
> "progl") inclsf+=( "${progl[@]}" ) ;;
> "pextd") inclsf+=( "${pextd[@]}" ) ;;
> "typog") inclsf+=( "${typog[@]}" ) ;;
> *) inclsf+=( "$el" ) ;;
> esac
> done
>
> if (( ${#incl[@]} > 0 )); then
>
> # Split INCL by field separator FS
> for ext in "${inclsf[@]}"; do
> [[ "$ext" =~ "{*}" ]] && echo "Detected {}"
> s="$ext"
> [[ (! -z "$fs") && ("$ext" == *"$fs"*) ]] && s=${ext//"$fs"/" "}
> for fltyp in $s; do
> isufx+=( --include="$fltyp" )
> done
> done
>
> fi
>
> grep --null -r -l "${isufx[@]}" -e "$phrs" -- "${fdir[@]}"
Why not just use brace expansion instead of trying to reimplement it?
incl_args=(--include=\*.{rc,el,c,f,cp,cpp,f90,f95,f03,f08})
grep "${incl_args[@]}" -- whatever
--
vq