我有“灯塔”功能,可操作一种与习俗环境变量相平的文字。 我想避免出口现金中的相关变量,而只是把这些变量作为执行指挥的一部分放在文字上。
If I set the variables directly in the command -- e.g., VARNAME=VARVAL script_name
-- it works well. However, since I want to set multiple variables, based on different conditions, I want to use a local function variable to store the environment variable settings, and then use this variable in the script execution command.
I have a local "vars" variable that is ultimately set, e.g., to VARNAME=VAR
, but if I try to run ${vars} script_name
from my bash function, I get a "command not found" error for the $vars variable assignment -- i.e., the content of $vars is interpreted as a command instead of as environment variables assignment.
I tried different variations of the command syntax, but so far to no avail. Currently I have to export the relevant variables in the function, before calling the script, and then unset/reset them to the previous values, but this is not really the solution I was hoping for.
任何帮助都将受到高度赞赏。
Thanks, Sharon