From a80bd12e4a033d93413678c2e271fa5ee34e06de Mon Sep 17 00:00:00 2001 From: gutmet Date: Wed, 29 Apr 2020 08:25:09 +0200 Subject: [PATCH] assign bash variables from output in function --- Sports/Concept2/PM5/pm5conv.bash | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Sports/Concept2/PM5/pm5conv.bash b/Sports/Concept2/PM5/pm5conv.bash index 72c362d..d53c0f6 100755 --- a/Sports/Concept2/PM5/pm5conv.bash +++ b/Sports/Concept2/PM5/pm5conv.bash @@ -1,10 +1,16 @@ #!/bin/bash -cmd="/home/alexander/Spielewiese/laymanshex/laymanshex" +cmd="laymanshex" accTable="LogDataAccessTbl.bin" storage="LogDataStorage.bin" +function assignVariables { + while read -r line; do + typeset -g "$line" + done <<< "$1" +} + i=0 while : ; do offset=$(($i*32)) @@ -13,17 +19,13 @@ while : ; do if [ $status -ne 0 ]; then break else - while read -r line; do - typeset -x "$line" - done <<< "$output" + assignVariables "$output" echo "Workout $Index" echo "=============" outputHeader="$($cmd -nopadding -fvar=offset=$Offset $storage-HeaderWorkout$WorkoutType.layhex $storage 2>/dev/null)" status=$? if [ $status -eq 0 ]; then - while read -r line; do - typeset -x "$line" - done <<< $outputHeader + assignVariables "$outputHeader" echo "TotalDuration=$HeaderTotalDuration" echo "TotalDistance=$HeaderTotalDistance" echo "SplitSize=$HeaderSplitSize"