On 21 April 2015 at 16:14, Liviu Ionescu <i...@livius.net> wrote:
> if you insist on the arg= solution, could you be so kind and
> provide a bash script wrapper that passes all arguments ($@)
> using your syntax?


If you're willing to accept bashisms, then:

argstr=""
for arg in "$@"; do
    argstr=${argstr:+$argstr,}arg=${arg//,/,,}
done

qemu-system-arm --semihosting-options "$argstr"


If you want pure POSIX shell then it is slightly
uglier as we have to invoke sed:

argstr=""
for arg in "$@"; do
     o=$(printf '%s.\n' "$arg" | sed s/,/,,/g)
     argstr=${argstr:+$argstr,}arg=${o%.}
done

qemu-system-arm --semihosting-options "$argstr"

(Note the trick with the '.' to ensure correct handling
of trailing newlines in arguments; credit to mdw for
that one.)

-- PMM

Reply via email to