Сквозные параметры (in-out)

Функции

#a function gets the names of the variables,
#local -n turns them into references (bash 4.3 and newer)
swapStrings() {
    local -n v1=$1
    local -n v2=$2
    local tmp=$v1
    v1=$v2
    v2=$tmp
}

s1="A"
s2="B"
swapStrings s1 s2
#s1 is "B", s2 is "A"

echo "s1 is $s1"
echo "s2 is $s2"