Browse Source

cleanup support/functions/_arrays

pull/16/head
gorgone 5 years ago
parent
commit
6fa4f83ff2
  1. 125
      support/functions/_arrays

125
support/functions/_arrays

@ -1,54 +1,85 @@
#!/bin/bash #!/bin/bash
_fill_tc_array(){ _fill_tc_array(){
unset AVAI_TCLIST; unset AVAI_TCLIST
unset INST_TCLIST; unset INST_TCLIST
tcempty=0; tcempty=0
cd "$tccfgdir";
[ "$(ls -A "$tccfgdir")" ] && AVAI_TCLIST=(*) || echo "error fix it"; cd "$tccfgdir"
cd "$tcdir"; if [ "$(ls -A "$tccfgdir")" ]
if [ "$(ls -A "$tcdir")" ];then then
tmp_tclist=(*); AVAI_TCLIST=(*)
for t in "${tmp_tclist[@]}";do else
for a in "${AVAI_TCLIST[@]}";do printf "\n error in _fill_tc_array()\n please report error\n\n"
[ "$t" == "$a" ] && INST_TCLIST+=($t); exit
done; fi
done;
cd "$tcdir"
if [ "$(ls -A "$tcdir")" ]
then
tmp_tclist=(*)
for t in "${tmp_tclist[@]}"
do
for a in "${AVAI_TCLIST[@]}"
do
[ "$t" == "$a" ] && INST_TCLIST+=($t)
done
done
else else
tcempty=1; tcempty=1
fi; fi
if [ "$tcempty" == "1" ];then
MISS_TCLIST=$(echo ${AVAI_TCLIST[@]} |sort); if [ "$tcempty" == "1" ]
then
MISS_TCLIST=$(echo ${AVAI_TCLIST[@]} |sort)
else else
MISS_TCLIST=($(for el in $(diff_array AVAI_TCLIST[@] INST_TCLIST[@]);do echo "$el";done |sort)); MISS_TCLIST=(
fi; $(for el in $(diff_array AVAI_TCLIST[@] INST_TCLIST[@])
}; do
printf "$el\n"
done |sort)
)
fi
}
_create_module_arrays(){ _create_module_arrays(){
i=0; i=0
for e in $(echo "$addons" | sed 's/WEBIF_//g;s/WITH_//g;s/MODULE_//g;s/CS_//g;s/HAVE_//g;s/_CHARSETS//g;s/CW_CYCLE_CHECK/CWCC/g;s/SUPPORT//g';);do for e in $(echo "$addons" | sed 's/WEBIF_//g;s/WITH_//g;s/MODULE_//g;s/CS_//g;s/HAVE_//g;s/_CHARSETS//g;s/CW_CYCLE_CHECK/CWCC/g;s/SUPPORT//g';)
SHORT_ADDONS+=($e); do
SHORT_MODULENAMES+=($e); SHORT_ADDONS+=($e)
done; SHORT_MODULENAMES+=($e)
for e in ${protocols//MODULE_/};do done
SHORT_PROTOCOLS+=($e);
SHORT_MODULENAMES+=($e); for e in ${protocols//MODULE_/}
done; do
for e in ${readers//READER_/};do SHORT_PROTOCOLS+=($e)
SHORT_READERS+=($e); SHORT_MODULENAMES+=($e)
SHORT_MODULENAMES+=($e); done
done;
for e in ${card_readers//CARDREADER_/};do for e in ${readers//READER_/}
SHORT_CARD_READERS+=($e); do
SHORT_MODULENAMES+=($e); SHORT_READERS+=($e)
done; SHORT_MODULENAMES+=($e)
for e in $addons $protocols $readers $card_readers;do done
ALL_MODULES_LONG+=($e);
done; for e in ${card_readers//CARDREADER_/}
for e in "${SHORT_MODULENAMES[@]}";do do
INTERNAL_MODULES["$e"]="${ALL_MODULES_LONG[i]}"; SHORT_CARD_READERS+=($e)
((i++)); SHORT_MODULENAMES+=($e)
done; done
};
for e in $addons $protocols $readers $card_readers
do
ALL_MODULES_LONG+=($e)
done
for e in "${SHORT_MODULENAMES[@]}"
do
INTERNAL_MODULES["$e"]="${ALL_MODULES_LONG[i]}"
((i++))
done
}
diff_array(){ diff_array(){
awk 'BEGIN{RS=ORS=" "}{NR==FNR?a[$0]++:a[$0]--}END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}"); awk 'BEGIN{RS=ORS=" "}{NR==FNR?a[$0]++:a[$0]--}END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}; }

Loading…
Cancel
Save