Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Insert variable in a script doesn't work for some variables in bash

Open benPearce1 opened this issue 8 months ago • 0 comments

Severity

Workaround available

Version

All versions

Latest Version

I could reproduce the problem in the latest build

What happened?

When calling get_octopusvariable in a bash script, variable names that contain quotes or backticks will not work when executed.

Reproduction

Create a variable containing a back tick or a quote For example:

Image

In a bash script step, use the insert variable functionality to insert the variable. The resultant generated code will be wrong.

echo $(get_octopusvariable "with a "quote"")
echo $(get_octopusvariable "with a `backtick`")

Output will do nothing for the quote mark, for the back tick it will error /etc/octopus/main/Work/POVAJjoFCUSgpHFVG8Plg/Script.sh: line 4: backtick: command not found

Error and Stacktrace


More Information

No response

Workaround

Workaround is to escape the quote and backticks inside the variable name

echo $(get_octopusvariable "with a \"quote\"")
echo $(get_octopusvariable "with a \`backtick\`")

benPearce1 avatar Feb 14 '25 05:02 benPearce1