assign bash variables from output in function

This commit is contained in:
gutmet 2020-04-29 08:25:09 +02:00
parent aebb6d04c8
commit a80bd12e4a

View File

@ -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"