Hi,
folgendes kleines Beispiel:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Demonstriert die Verwendung von Parametern # Name: afunc18 # Globale Variable var="ich bin global" # Funktion localtest localtest() { local var="ich bin local" alocaltest } #Funktion alocaltest alocaltest() { echo $var } # Hauptfunktion localtest |
Warum wird echo $var
in der Funktion alocaltest nicht ausgeführt? Ich rufe die Funktion localtest auf und dort rufe ich ja eine weitere Funktion auf → alocaltest. Ich habe deshalb erwartet, dass ich als Ausgabe 2x "ich bin local" erhalte und nicht 1x.
Danke!