From b556594cb27d99803cb725a83a758b122de20da7 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 7 Oct 2023 11:48:02 -0400 Subject: [PATCH] Simplify some functions to accept label instead of line --- fgen.sh | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/fgen.sh b/fgen.sh index 385e211..86e9b55 100755 --- a/fgen.sh +++ b/fgen.sh @@ -57,11 +57,12 @@ function get_label() echo "${token}" } -# Arg1: line +# Arg1: label function get_frame_id() { - frame=$(echo "${1}" | grep -e "label:[0-9]\+" | ${SED} "s/.*label:\([0-9]\+\).*,geometry.*/\1/g") - echo "${frame}" + local token + token=$(echo "${1}" | grep -e "^[0-9]\+" | ${SED} "s/^\([0-9]\+\).*/\1/g") + echo "${token}" } # Arg1: line @@ -72,11 +73,12 @@ function get_scene_id() echo "${token}" } -# Arg1: line +# Arg1: label function get_group_id() { - group=$(echo "${1}" | grep -e "label:groupe.*" | ${SED} "s/.*label:groupe-\(.*\),geometry.*/\1/g") - echo "${group}" + local token + token=$(echo "${1}" | grep -e "^groupe" | ${SED} "s/^groupe-\(.*\)/\1/g") + echo "${token}" } # Arg1: group name @@ -87,20 +89,22 @@ function get_group_ref() echo "${token}" } -# Get duplicate from. Ex: "label:dup1-7 planXYZ,geometry..." will return 1 -# Arg1: line +# Get duplicate from. Ex: "dup1-7 planXYZ,geometry..." will return 1 +# Arg1: label function get_dup_from() { - dup=$(echo "${1}" | grep -e "label:dup.*" | ${SED} "s/.*label:dup\([0-9]\+\)-.*,geometry.*/\1/g") - echo "${dup}" + local token + token=$(echo "${1}" | grep -e "^dup" | ${SED} "s/^dup\([0-9]\+\)-.*/\1/g") + echo "${token}" } -# Get duplicate to. Ex: "label:dup1-7 planXYZ,geometry..." will return 7 -# Arg1: line +# Get duplicate to. Ex: "dup1-7 planXYZ,geometry..." will return 7 +# Arg1: label function get_dup_to() { - dup=$(echo "${1}" | grep -e "label:dup.*" | ${SED} "s/.*label:dup[0-9]\+-\([0-9]\+\).*,geometry.*/\1/g") - echo "${dup}" + local token + token=$(echo "${1}" | grep -e "^dup" | ${SED} "s/^dup[0-9]\+-\([0-9]\+\).*/\1/g") + echo "${token}" } function generate_video() @@ -222,10 +226,11 @@ if [ ${trames} -eq 1 ]; then scene=$(get_scene_id "${l}") label=$(get_label "${l}") p=$(get_pos "${l}") - nf=$(get_frame_id "${l}") - ng=$(get_group_id "${l}") - dup_from=$(get_dup_from "${l}") - dup_to=$(get_dup_to "${l}") + + nf=$(get_frame_id "${label}") + ng=$(get_group_id "${label}") + dup_from=$(get_dup_from "${label}") + dup_to=$(get_dup_to "${label}") # Also indicate a new frame, but to be copied from..to: if [ x"${dup_from}" != x"" ]; then -- 2.20.1