Artificial intelligent assistant

unset a variable and then use its value In a `source`d file, I want to return the exit status of a particular command, which I store in the variable `return_val`. How do I unset this variable (so as not to pollute the name space), and still return it's value?

If you're using a shell that supports local variables, such as ksh, bash or zsh, put all the code in functions and declare all variables as local.

With plain sh, you can use `eval` to perform the variable expansion before using the value. A return status only contains digits, so you don't even need tricky quoting.


eval "unset return_status; return $return_status"

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3e7c96aa778ec1153a4c2081f55ee2e6