输入变量包含:
key1-key2-key3_command
输出需要:
command -k key1 -k key2 -k key3
警告:键的数量可以从 1 到 3 不等。
I've counted the number of dashes and use that with an if statement to create a Boolean indicator for each key (ie. key1=1, unset key2). Then I was going to use something like ${parameter:+word}
to add in the key if the flag for that key is set. It started getting a bit messy so I thought I'd ask here on what the best way to achieve this would be.