#!/usr/bin/env bash # ------------------------------------------------------------- # build_and_rename.sh # # Usage: # ./build_and_rename.sh [any extra options] # # Every positional argument you give here will be appended # (verbatim) after the entry‑specific options when invoking # `./build.sh`. # ------------------------------------------------------------- set -euo pipefail # Fail fast, treat unset variables as errors #################################### ## 1. Configuration (inline) #################################### rm -rf Handbooks mkdir -p Handbooks entries=( "Handbooks/Player_handbook_eduald -o origines_stats_handbook_abyssal_1" "Handbooks/Player_handbook_michel -o fra" # Add more lines like above as needed ) #################################### ## 2. Forwarded arguments #################################### # All arguments that the user typed after the script name. wrapper_opts=("$@") # Empty array if no args were given. #################################### ## 3. Main loop – process each entry #################################### for entry in "${entries[@]}"; do # Split entry into: # * $output_name – first word (everything before the first space) # * $options – everything after that first word output_name="${entry%% *}" # text before first space options="${entry#$output_name }" # text after that space echo "=== Building for '$output_name' ===" echo " entry options : ${options}" echo " wrapper opts : ${wrapper_opts[*]}" # Run the real build script. # # - `player` is fixed before any options # - `$options` expands into its constituent arguments (unquoted) # - `"${wrapper_opts[@]}"` appends whatever the user typed after # this wrapper script, *verbatim*. ./build.sh "${wrapper_opts[@]}" player $options # The build step is expected to produce a file named: # Player_handbook_build.pdf # (adjust if your build writes somewhere else). mv -f Player_handbook_build.pdf "${output_name}.pdf" echo "'${output_name}.pdf' created." done echo echo "All entries processed successfully!"