I am trying to change the values inside an array that is a copy of arguments array ("$@"
). Let's say I execute the script as follows: $ sh script.sh 1 2 3
This is the script:
list="$@"
echo ${list[*]}
list[1]=4
echo ${list[*]}
Expected output:
1 2 3
1 4 3
What I actually get:
1 2 3
1 2 3 4
Any idea what causes this behavior and how can I fix it?