I'm working with a utility (unison, but that's not the point) that accepts parameters like:
$ unison -path path1 -path path2 -path path3
I would like to write a sh script that I could run like this:
$ myscript path1 path2 path3
I'm hoping for a Posix compliant solution, but bash-specific would also be good.
I'm guessing it should be something like:
#!/bin/sh
unison ${*/ / -path }
But this doesn't work.
EDIT: OK, I think I got something:
#!/bin/bash
PARAMS=
for arg in "$@"
do
PARAMS+=" -path '$arg'"
done
unison $PARAMS
The problems are this only works in bash, and I'm pretty sure there's a better way to quote the parameters.