#$1 is a copy: the function may change it,
#the variable of the caller stays the same
print_max5() {
local data=$1
if ((${#data} > 5)); then
data=${data:0:5}
fi
echo "$data"
}
data="1234567"
print_max5 "$data"
#printed "12345"
#data is "1234567"
#a trap: a variable without local is the global one,
#and the function changes it for the caller
cut3() {
text=${text:0:3}
}
text="abcdef"
cut3
#text is "abc"
echo "data is $data"
echo "text is $text"