Sample Header Ad - 728x90

Bash local nameref declaration does not work

-1 votes
1 answer
110 views
I am trying to set a local variable in a function with nameref. The script code is the following: #!/usr/bin/bash msg=hello myparam='' superfunc () { productfile=$1 local -n refmyparam=$2 } superfunc $msg $myparam echo $myparam When running it I get the error: line 7: local: `': not a valid identifier We use **GNU bash, version 5.2.21**
Asked by trikelef (460 rep)
Dec 3, 2024, 11:29 AM
Last activity: Dec 4, 2024, 08:12 AM