So I have this function in bash that receives as first parameter an empty string variable and as second parameter a character,function check_cases {    case $2 in        r) $1=$(echo $1 Read);;        w) $1=$(echo $1 Write);;        x) $1=$(echo $1 Execution);;    esac}I've tried all different ways to concatenate the string variable but it always says that=: command not foundabout the = operator. I create and empty local string variable inside a function like local var=And pass it with a character variablecheck_cases $var $charI want to understand what's going on and how to solve this problem.
Modifying empty string variable inside switch statement in function bash
bash;shell script
It looks like you're trying to do a pass by reference type function.These aren't really a good fit for for bash scripting.  We can fake it with the eval command, but this has a lot of risky behaviour (potential evaluation of commands embedded in strings) and so isn't recommend.In this example, the code would look something like:function check_cases {    case $2 in        r) eval $1=\\$$1 Read\ ;;        w) eval $1=\\$$1 Write\ ;;        x) eval $1=\\$$1 Execution\ ;;    esac}check_cases var rcheck_cases var wcheck_cases var xecho $varInstead it's normally better to use pass by value semantics; just return the value you want and have the caller append it to the variable.e.g.function check_cases {    case $1 in        r) echo  Read ;;        w) echo  Write ;;        x) echo  Execution ;;    esac}var=$var$(check_cases r)var=$var$(check_cases w)var=$var$(check_cases x)echo $var