Replacing multiple strings with another set of multiple strings becomes messy if you want to use standard parameter handling. Usually, commands take a set of atomic parameters, and then a set of atomic arguments, and the sequence doesn't matter other than that arguments come after parameters (separated by -- if ambiguous). How would you construct the synopsis in this case?
Here's a simple function which should do the job for simple replacements:
$ trs() {
local string=$1
shift
for replacement in "$@"
do
string="$(sed -e "s/$replacement/g" <<< "$string")"
done
printf "$string"
}
$ trs '1 2 3' '1/foo' '2 3/bar baz'
foo bar baz
Alternatively you could work with pairs of parameters:
$ trs() {
local string=$1
shift
while [ $# -gt 0 ]
do
string="$(sed -e "s/$1/$2/g" <<< "$string")"
shift 2
done
printf "$string"
}
$ trs '1 2 3' 1 foo '2 3' 'bar baz'
foo bar baz