diff --git a/chertex.sh b/chertex.sh index 0704f26..de79634 100755 --- a/chertex.sh +++ b/chertex.sh @@ -158,7 +158,7 @@ aux_tikz="*-tikzDictionary" aux_tdo="*.tdo" aux_toc="*.toc" aux_xdy="*.xdy" # glossaries (xindy) -# all aux files in a string +# all aux files in a single string auxfiles="${aux_acn} ${aux_acr} ${aux_alg} ${aux_aux} ${aux_bbl} ${aux_blg} ${aux_dep} ${aux_dpth} ${aux_fdb} ${aux_fig} ${aux_fls} ${aux_glg} ${aux_glo} ${aux_gls} ${aux_ist} ${aux_lob} ${aux_lof} ${aux_log} ${aux_lol} ${aux_lor} ${aux_los} ${aux_lot} ${aux_maf} ${aux_out} ${aux_lox} ${aux_make} ${aux_map} ${aux_mtc} ${aux_run} ${aux_slg} ${aux_slo} ${aux_sls} ${aux_stc} ${aux_tikz} ${aux_tdo} ${aux_toc} ${aux_xdy}" @@ -365,8 +365,22 @@ else fi if [[ $usrchoice == "clean-up" || $usrchoice == "2" ]]; then msg "<2> 'clean-up' chosen" - rm $auxfiles - # Still, a rather crude way of cleaning up... + # in $auxfiles, strip "*." or "*" at beginning of each word and "*" at the + # end of any word, and replace space between items with pipe symbol + # using the built-in bash ${$VAR//find/replace} takes us part-way + # $ echo "${auxfiles//\*./}" + # acn acr alg aux bbl blg dep dpth fdb* figlist fls glg glo gls* ist lob lof log lol lor los lot maf out lox makefile map mtc* run* slg slo sls stc* *-tikzDictionary tdo toc xdy + # https://www.baeldung.com/linux/process-a-bash-variable-with-sed + # first, replace "*." or "*-" with empty string, then replace "* " with ".* " (to suit + # regex syntax in the subsequent find command), finally replace each inter-word + # spaces with pipe symbol. Also, and this is important, "*-tikzDictionary" needs to + # be cleaned up otherwise trips up the -iregex parameter! (don't leave "*-" in the string) + # https://unix.stackexchange.com/a/15337 + # $ echo "$auxfiles" | sed -r "s/\*\.//g" | sed -r "s/\* /\.\* /g" | sed -r "s/ /|/g" + # acn|acr|alg|aux|bbl|blg|dep|dpth|fdb.*|figlist|fls|glg|glo|gls.*|ist|lob|lof|log|lol|lor|los|lot|maf|out|lox|makefile|map|mtc.*|run.*|slg|slo|sls|stc.*|*-tikzDictionary|tdo|toc|xdy + auxregex=$(echo "$auxfiles" | sed -r "s/\*[\.-]//g" | sed -r "s/\* /\.\* /g" | sed -r "s/ /|/g") + # "rm -v" provides nice output of which files were cleaned up + find "$path_thesis" -maxdepth 1 -type f -regextype posix-extended -iregex ".*\.($auxregex)" -exec rm -v "{}" \; fi if [[ $usrchoice == "wipe-dir" || $usrchoice == "3" ]]; then msg "<3> 'wipe-dir' chosen"