I was struggling pretty hard to run some subcommands to perform some string manipulation. I was both unfamiliar with different shell variations and the intricacies of YAML. I really was just trying to figure out how to feed the string results of this command below into another command.
expr 'aaw-ABCD-1234-otherchars1234' : '\([a-z]*-[A-Z]*-[1-9]*\)' | tr [A-Z] [a-z]
I ended up figuring out how to do it by putting subcommands into variables.
I had moved to trying this out from the Gitlab Pipeline Editor because of helpful syntax checks and highlighting. However, I think there is a bug where the Editor doesn’t respect values that have colons in them even when the entire value is surrounded by single quotes.
PREFIX_A and PREFIX_B variables have incorrect syntax highlighting differentiating the key from the value. The second colon is a part of the expr command, not the separator between a key and value for YAML.
Here’s a screenshot of the runner output showing that the job succeeded:
All of the output returned as expected (even if I’m still a little naive as to why…I’m still learning about the intricacies of the $ operator).
This is the GitLab documentation that I used (correctly claiming that single quotes will allow the usage of colons in commands:
Could we create a ticket for fixing the Editor’s syntax highlighter for commands that have colons in them that are properly encompassed by single quotes? I know that technically my command was in a variable, but the current highlighting is misleading when commands are written in the variables section or the scripts section.
What version are you on?
- Gitlab: GitLab Enterprise Edition 15.2.2-ee
- Runner: 15.3.0