If I pass variable as a positional argument to a function, is it possible to determine the name of the variable used from inside the function, or I can only access its value?
I have a function envir-export that I can use to define an environment variable and store it in a special environment file that would then get sourced.
envir-export ()
{
nm="$1"
vl="$2"
envirs_trkrc="${HOME}/Opstk/envirs"
echo "export ${nm}=${vl}" >> ${envirs_trkrc}/envirs.rc
source ${envirs_trkrc}/envirs.rc
echo "$nm exported with value $vl"
}
Currently I am using by the following call
envir-export VERBOS 8
Using the name VERBOS with value 8.
I would like to improve on this function, both in convenience, and also functionally.
For instance, if no value is supplied then I only export the name with a value being assigned.