I am having trouble with what should be a simple bash script.I have a bash script that works perfectly:function convert_to ()x_max=2038y_max=1146x_marg=100y_marg=30x_grid=150y_grid=150if (($x_pos > ($x_marg+($x_grid/2)))); then    x_pos=$((x_pos-x_marg))    x_mod=$((x_pos%x_grid))    x_pos=$((x_pos/x_grid))    x_pos=$((x_pos*x_grid))fiHowever, I want to change the script where I pass 4 values to the function as arguments: function convert_to ()pos=$1marg=$2grid=$3max=$4# I verify that the inputs have arrived with this display zenity --info --title Info --text inputs: pos: $pos marg: $marg grid: $grid max: $maxif (($pos > ($marg+($grid/2)))); then    pos=$((pos-marg))    mod=$((pos%grid))    pos=$((pos/grid))    pos=$((pos*grid))fi}Where I would then call the function as follows:x_pos=$(convert_coordinates $x_pos, $x_marg, $x_grid, $x_max)Y_pos=$(convert_coordinates $y_pos, $y_marg, $y_grid, $y_max)However, the new script always fails with syntax errors: operand expected (error token is ,).I've also tried many variations:pos=$[[ $pos - $marg ]] ...... which results in syntax error: operand expected (error token is [ 142, - 100, ])pos=[[ $pos - $marg ]] .......... fails with command not foundpos=$[[ $pos - $marg ]] ..... fails with command not foundpos=$(($pos-$marg)) ......... syntax error: operand expected (error token is 142,-100,)The only difference between the working script and non-working is the fact that I am passing the arguments in the second script ... So, i tried setting the argument values to constant values within the function (defeating my purpose of passing arguments and making the script worthless) .. But, now the calculations within the function are working without error.So I'm at a loss for what I am doing incorrectly ... I want to be able to pass arguments to the function and then do mathematical calculations using the passed values.
functions arguments
bash;scripting;function;arguments
In bash, the argument separators are spaces, so :instead of :x_pos=$(convert_coordinates $x_pos, $x_marg, $x_grid, $x_max)do x_pos=$(convert_coordinates $x_pos $x_marg $x_grid $x_max)