|
|
@ -134,10 +134,33 @@ if [ $# -eq 1 ]; then
|
|
|
|
# find all files named "assets.external" in the assets/ tree
|
|
|
|
# find all files named "assets.external" in the assets/ tree
|
|
|
|
assetsexternalfiles=$(find "$path_wd/assets/" -type f -name "assets.external")
|
|
|
|
assetsexternalfiles=$(find "$path_wd/assets/" -type f -name "assets.external")
|
|
|
|
for externalfilepath in $assetsexternalfiles; do
|
|
|
|
for externalfilepath in $assetsexternalfiles; do
|
|
|
|
# this weird-looking while-loop reads the assets.external file line-by-line and copies each asset into the target path inside the thesis' assets/ tree
|
|
|
|
|
|
|
|
# https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable
|
|
|
|
# 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
|
|
|
|
while IFS='' read -r asset || [[ -n "$asset" ]]; do
|
|
|
|
|
|
|
|
# $asset contains one line from the current external.assets
|
|
|
|
|
|
|
|
# assetpathtarget is the directory of the current external.assets file
|
|
|
|
assetpathtarget=$(dirname "$externalfilepath")
|
|
|
|
assetpathtarget=$(dirname "$externalfilepath")
|
|
|
|
|
|
|
|
# if $asset contains a space, the second element should be considered a local target folder for the copy operation
|
|
|
|
|
|
|
|
# https://www.tutorialkart.com/bash-shell-scripting/bash-split-string/
|
|
|
|
|
|
|
|
# https://stackoverflow.com/a/30212526
|
|
|
|
|
|
|
|
IFS=' ' # reset IFS
|
|
|
|
|
|
|
|
# asset is read into an array as tokens separated by IFS
|
|
|
|
|
|
|
|
read -ra asset_array <<< "$asset"
|
|
|
|
|
|
|
|
# sanity check for array length
|
|
|
|
|
|
|
|
if [ ${#asset_array[@]} -gt 2 ]; then
|
|
|
|
|
|
|
|
echo "<thesis> Cannot handle more than one space per line"
|
|
|
|
|
|
|
|
echo "<cheRTeX> Terminating..."
|
|
|
|
|
|
|
|
simpledelay.sh 2
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${#asset_array[@]} -gt 1 ]; then
|
|
|
|
|
|
|
|
# echo "Placing this asset into subdirectory ${asset_array[1]}"
|
|
|
|
|
|
|
|
# redefine assetpathtarget to include the local subdir
|
|
|
|
|
|
|
|
assetpathtarget="$assetpathtarget/${asset_array[1]}"
|
|
|
|
|
|
|
|
# also redefine $asset so we keep only the asset path
|
|
|
|
|
|
|
|
asset="${asset_array[0]}"
|
|
|
|
|
|
|
|
# create the local subdir inside assets/<current/
|
|
|
|
|
|
|
|
mkdir -p "$assetpathtarget" # -p suppresses error if dir already exists
|
|
|
|
|
|
|
|
fi
|
|
|
|
echo "<thesis> Copying $asset to $assetpathtarget"
|
|
|
|
echo "<thesis> Copying $asset to $assetpathtarget"
|
|
|
|
# cp but don't overwrite existing files
|
|
|
|
# cp but don't overwrite existing files
|
|
|
|
cp --preserve=timestamps --no-clobber $asset $assetpathtarget
|
|
|
|
cp --preserve=timestamps --no-clobber $asset $assetpathtarget
|
|
|
|