From 1d0d8f39503f071fb364c12ad9a7333bc5f83641 Mon Sep 17 00:00:00 2001 From: "taha@asks2" Date: Fri, 8 Jun 2018 06:06:25 +0200 Subject: [PATCH] chertex.sh now reads and fetches external assets for thesis --- chertex.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/chertex.sh b/chertex.sh index 34f9bd0..c76a30b 100755 --- a/chertex.sh +++ b/chertex.sh @@ -83,6 +83,35 @@ if [ $# -eq 1 ]; then exit 0 fi + #### Special treatment for thesis + # If $jobname is thesis, fetch some external assets + if [[ ${PWD} == "/media/bay/taha/chepec/thesis" && $jobname == "thesis" ]]; then + echo " -------------------------------" + echo " THESIS: getting external assets" + echo " -------------------------------" + # summary of operations in this if-clause: + # trawl the assets/ subdirectories looking for a file "external.assets", if found, + # read its contents line-by-line (each line is a path) and copy that file to the current assets/ subdir + # note that we only look for assets.external inside the subdirectories, and not in assets/ itself + assetsubdirectories="$(find /media/bay/taha/chepec/thesis/assets/ -maxdepth 1 -mindepth 1 -type d)" + # loop through $assetdirs, and look for the file external.assets in each path + for assetdir in $assetsubdirectories; do + assetfilename="assets.external" + if [ -e ${assetdir}/${assetfilename} ]; then + # https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable + # $assets is the current assets.external file + assets="${assetdir}/${assetfilename}" + while IFS='' read -r asset || [[ -n "$asset" ]]; do + echo "$asset" + # copy this filepath into the current assets subdirectory + cp --preserve=timestamps $asset $assetdir + done < "$assets" + fi + done + fi + # short delay to enable on-screen reading of previous echo + simpledelay.sh 1 + ## Handle knitr or pgfSweave jobs (each requires separate treatment) ## But how should we tell the difference between them?