summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2026-02-25 21:02:08 +0100
committerDennis Fink2026-02-25 21:03:25 +0100
commitd2de34528dd9ed67957b09b294abb28154d4a4c6 (patch)
treed6b9ff276c9c66a01ab78fe3362254110b1e8657
parent71ee4e8b74e8c9eeeb5529ce17f922418f800b38 (diff)
downloadtranscode.sh-d2de34528dd9ed67957b09b294abb28154d4a4c6.tar.gz
transcode.sh-d2de34528dd9ed67957b09b294abb28154d4a4c6.zip
revert(preset): return ffargs via nameref instead of global variable
Reverts commit b10b81fefbe529be7db14ca65ec4b4a293782d39. The nameref approach did not work as intended; reverting to restore correct behaviour.
Diffstat (limited to '')
-rwxr-xr-xtranscode.sh18
1 files changed, 3 insertions, 15 deletions
diff --git a/transcode.sh b/transcode.sh
index 527c15c..a5a91d8 100755
--- a/transcode.sh
+++ b/transcode.sh
@@ -347,10 +347,6 @@ fi
# Load ffmpeg argument preset by name.
#
-# Arguments:
-# $1 - preset name
-# $2 - name of the caller's array variable to populate (nameref)
-#
# Security:
# Presets are sourced as shell code. Names are validated against a strict
# allowlist (alphanumerics, hyphens, underscores only) to prevent path
@@ -362,12 +358,8 @@ fi
# The sourced preset MUST set the bash array `ffargs`.
# Presets may reference variables from the caller (encode_one) such as:
# output_pixel_format, input_pixel_format, input_codec
-# On return the caller's array (named by $2) is populated with the preset's
-# ffargs; the preset-local `ffargs` variable is unset before returning.
load_preset() {
local preset="$1"
- local -n _load_preset_out="$2"
-
# Strict allowlist: only alphanumerics, hyphens, and underscores are permitted.
# This prevents path traversal, shell metacharacter injection, and symlink-based
# attacks more reliably than a blocklist approach.
@@ -397,7 +389,8 @@ load_preset() {
exit $EXIT_CONFIG_ERROR
fi
- local ffargs=()
+ unset -v ffargs
+ ffargs=()
debug "Sourcing preset file:" "$file"
@@ -410,8 +403,6 @@ load_preset() {
}
debug "Preset ffargs:" "$(printf "%q " "${ffargs[@]}")"
-
- _load_preset_out=("${ffargs[@]}")
}
if [[ $# -eq 0 ]]; then
@@ -705,10 +696,7 @@ encode_one() {
output_pixel_format="yuv${subsampling}${depth}"
debug "Selected output pixel format:" "$output_pixel_format"
- # Load preset early so a missing/invalid preset fails before we create a
- # temp file or do any further work.
- local ffargs=()
- load_preset "$PRESET_NAME" ffargs
+ load_preset "$PRESET_NAME"
local extension directory tmp base stem
# filename (path without extension) is used only for the savings log.