Input variable contains:
key1-key2-key3_command
Output needs to be:
command -k key1 -k key2 -k key3
Caveat: Number of keys can vary from 1 to 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.