diff --git a/chertex.sh b/chertex.sh index 3dd4372..59d8725 100755 --- a/chertex.sh +++ b/chertex.sh @@ -138,9 +138,15 @@ if [ $# -eq 1 ]; then # https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable while IFS='' read -r asset || [[ -n "$asset" ]]; do assetpathtarget=$(dirname "$externalfilepath") - echo "Copying $asset to $assetpathtarget" - # cp but don't overwwrite existing files + echo " Copying $asset to $assetpathtarget" + # cp but don't overwrite existing files cp --preserve=timestamps --no-clobber $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" + assetdirnametarget=$(basename "$assetpathtarget") + if [[ $assetdirnametarget == "references" ]]; then + echo " Overwriting BibTeX libraries in assets/references/" + cp --preserve=timestamps $asset $assetpathtarget + fi done < "$externalfilepath" done