assign bash variables from output in function
This commit is contained in:
parent
aebb6d04c8
commit
a80bd12e4a
|
@ -1,10 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cmd="/home/alexander/Spielewiese/laymanshex/laymanshex"
|
cmd="laymanshex"
|
||||||
|
|
||||||
accTable="LogDataAccessTbl.bin"
|
accTable="LogDataAccessTbl.bin"
|
||||||
storage="LogDataStorage.bin"
|
storage="LogDataStorage.bin"
|
||||||
|
|
||||||
|
function assignVariables {
|
||||||
|
while read -r line; do
|
||||||
|
typeset -g "$line"
|
||||||
|
done <<< "$1"
|
||||||
|
}
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
while : ; do
|
while : ; do
|
||||||
offset=$(($i*32))
|
offset=$(($i*32))
|
||||||
|
@ -13,17 +19,13 @@ while : ; do
|
||||||
if [ $status -ne 0 ]; then
|
if [ $status -ne 0 ]; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
while read -r line; do
|
assignVariables "$output"
|
||||||
typeset -x "$line"
|
|
||||||
done <<< "$output"
|
|
||||||
echo "Workout $Index"
|
echo "Workout $Index"
|
||||||
echo "============="
|
echo "============="
|
||||||
outputHeader="$($cmd -nopadding -fvar=offset=$Offset $storage-HeaderWorkout$WorkoutType.layhex $storage 2>/dev/null)"
|
outputHeader="$($cmd -nopadding -fvar=offset=$Offset $storage-HeaderWorkout$WorkoutType.layhex $storage 2>/dev/null)"
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
while read -r line; do
|
assignVariables "$outputHeader"
|
||||||
typeset -x "$line"
|
|
||||||
done <<< $outputHeader
|
|
||||||
echo "TotalDuration=$HeaderTotalDuration"
|
echo "TotalDuration=$HeaderTotalDuration"
|
||||||
echo "TotalDistance=$HeaderTotalDistance"
|
echo "TotalDistance=$HeaderTotalDistance"
|
||||||
echo "SplitSize=$HeaderSplitSize"
|
echo "SplitSize=$HeaderSplitSize"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user