Für etwas, was mehr "sophisticated" ist, immer bash.
Was auch bei Funktionen in bash toll ist, ist, dass sie Argumente annehmen können.
BTW: Den Rekord des schlimmsten Shell-Scripts aller Zeiten beanspruche eh ich...
Mal ein Auszug aus einem ganz schlimmen Script, das ich früher mal schrieb:
Code: Alles auswählen
[...]
for ((q=1; q<=4; q++)); do
if (( q == 1 )); then
TEST
tput cup $(($(($((q-1))*2*QUANT+1+q-y))*x)) 0
for ((l=1; l<=QUANT; l++)); do
echo $(echo -e "${NUM[$l]}\n" &)
done
for ((l=2; l<=QUANT; l++)); do
if (( l <= 3 )); then
for ((i=$((l-1)); i>=$((l-$((l-1)))); i--)); do
TEST
tput cup $(($(($((l*2-1-$((l-i))))+$((q-1))*2*QUANT+q-y))*x)) $(($((l-i))*$((2+QUANTC))))
echo $(echo "${NUM[$l]}-${NUM[$i]}" | bc &)
done
else
for ((i=$((l-1)); i>=$((l-3)); i--)); do
TEST
tput cup $(($(($((l*2-1-$((l-i))))+$((q-1))*2*QUANT+q-y))*x)) $(($((l-i))*$((2+QUANTC))))
echo $(echo "${NUM[$l]}-${NUM[$i]}" | bc &)
done
fi
done
elif (( q == 2 )); then
[...]
Code: Alles auswählen
[...]
countalign3=$(($(printf "%s\n" ${zielspalte[@]} | wc -L)+1))
if (( countalign2 <= countalign3 )); then countalignmax=$countalign3; else countalignmax=$countalign2; fi
for ((l=1; l<=count; l++)); do
for ((i=1; i<=indent; i++)); do printf "%s" " "; done
printf "%s" "| " && printf "%s\n" ${line2[l]} | while read number; do printf %"$countalignmax"s "$number"; done
if (( l == 1 )); then printf "%s" " (2. Matrix)"; fi
printf "\n"
done
count3=$((countalignmax*$(wc -w <<< ${line2[1]})+countalign*count+5))
for ((i=1; i<=count3; i++)); do printf "%s" "–"; done && printf "\n"
for ((l=1; l<=lines; l++)); do
printf "%s\n" ${line[l]} | while read number; do printf %"$countalign"s "$number"; done && printf "%s" " | "
printf "%s\n" ${zielzeile[l]} | while read number; do printf %"$countalign3"s "$number"; done
if (( l == 1)); then printf "%s\n" " (Ergebnis)"; else printf "\n"; fi
done
printf "\n"