From 5a73e3e49dec724fbbb6239b988e9c699b3c36ab Mon Sep 17 00:00:00 2001 From: "taha@asks2" Date: Fri, 9 Jun 2023 01:15:54 +0200 Subject: [PATCH] Fixed a bug: path_thesis should be path_wd. + gave the die() function a way to customise the sleep duration (allows the clean-up step to terminate immediately without waiting), and removed its unused exit-code argument. --- chertex.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/chertex.sh b/chertex.sh index de79634..ce3ec1c 100755 --- a/chertex.sh +++ b/chertex.sh @@ -48,15 +48,18 @@ msg() { echo >&2 -e "${1-}" } -# examples: -# die "Some message (exiting with status 1)" -# die "Some message (exiting with status -->)" 0 # this is not working +# Examples: +# die "some message" +# die "some message and wait 6 seconds before exiting" 6 +# die "some message and exit immediately" 0 die() { local msg=$1 - local code=${2-1} # default exit status 1 msg "$msg" - simpledelay.sh 2 # short delay to aid reading last message in case terminal closes on exit - exit "$code" + # short delay to aid reading last message in case terminal closes on exit + # if $2 was provided, set it as delay + # if $2 is unset or null, use a 3 second delay + simpledelay.sh ${2:-3} + exit 0 } parse_params() { @@ -226,10 +229,12 @@ if [[ $show_menu == "false" ]]; then msg " Copying $asset to $assetpathtarget" # cp but don't overwrite existing files cp --preserve=timestamps --no-clobber --recursive $asset $assetpathtarget - # except we want to overwrite the BibTeX library files (inside the assets/references/ directory), we'll do that by checking the target dirname and only running the destructive cp operation if its "references" + # except we want to overwrite the biblatex library file (inside the assets/references/ directory) + # as well as the zotero.sqlite file, we'll do that by checking the target dirname and only run + # the copy operation (which will overwrite stuff) if it is "references" assetdirnametarget=$(basename "$assetpathtarget") if [[ $assetdirnametarget == "references" ]]; then - msg " Overwriting BibTeX libraries in assets/references/" + msg " Overwriting Zotero biblatex library and database in assets/references/" cp --preserve=timestamps $asset $assetpathtarget fi done < "$externalfilepath" @@ -380,7 +385,7 @@ else # 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 "{}" \; + cd "$path_wd" && find . -maxdepth 1 -type f -regextype posix-extended -iregex ".*\.($auxregex)" -exec rm -v "{}" \; && cd $OLDPWD fi if [[ $usrchoice == "wipe-dir" || $usrchoice == "3" ]]; then msg "<3> 'wipe-dir' chosen" @@ -431,7 +436,7 @@ else fi fi - die "All done. Exiting..." + die "All done. Exiting..." 0 fi