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.
master
Taha Ahmed 1 year ago
parent c965437a0f
commit 5a73e3e49d

@ -48,15 +48,18 @@ msg() {
echo >&2 -e "${1-}" echo >&2 -e "${1-}"
} }
# examples: # Examples:
# die "Some message (exiting with status 1)" # die "some message"
# die "Some message (exiting with status -->)" 0 # this is not working # die "some message and wait 6 seconds before exiting" 6
# die "some message and exit immediately" 0
die() { die() {
local msg=$1 local msg=$1
local code=${2-1} # default exit status 1
msg "$msg" msg "$msg"
simpledelay.sh 2 # short delay to aid reading last message in case terminal closes on exit # short delay to aid reading last message in case terminal closes on exit
exit "$code" # 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() { parse_params() {
@ -226,10 +229,12 @@ if [[ $show_menu == "false" ]]; then
msg "<thesis> Copying $asset to $assetpathtarget" msg "<thesis> Copying $asset to $assetpathtarget"
# cp but don't overwrite existing files # cp but don't overwrite existing files
cp --preserve=timestamps --no-clobber --recursive $asset $assetpathtarget 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") assetdirnametarget=$(basename "$assetpathtarget")
if [[ $assetdirnametarget == "references" ]]; then if [[ $assetdirnametarget == "references" ]]; then
msg "<thesis> Overwriting BibTeX libraries in assets/references/" msg "<thesis> Overwriting Zotero biblatex library and database in assets/references/"
cp --preserve=timestamps $asset $assetpathtarget cp --preserve=timestamps $asset $assetpathtarget
fi fi
done < "$externalfilepath" 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 # 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") 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 # "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 fi
if [[ $usrchoice == "wipe-dir" || $usrchoice == "3" ]]; then if [[ $usrchoice == "wipe-dir" || $usrchoice == "3" ]]; then
msg "<3> 'wipe-dir' chosen" msg "<3> 'wipe-dir' chosen"
@ -431,7 +436,7 @@ else
fi fi
fi fi
die "All done. Exiting..." die "All done. Exiting..." 0
fi fi

Loading…
Cancel
Save