The following shell script takes a list of arguments, turns Unix paths into WINE / Windows paths, and calls the given executable in WINE.
#! /bin/sh
if [ "${1+set}" != "set" ]
then
echo "Usage; winewrap EXEC [ARGS...]"
exit 1
fi
EXEC="$1"
shift
ARGS=""
for p in "$@";
do
if [ -e "$p" ]
then
p=$(winepath -w $p)
fi
ARGS="$ARGS '$p'"
done
CMD="wine '$EXEC' $ARGS"
echo $CMD
$CMD
However, something is wrong with the quote of command line arguments.
$ winewrap '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' -smt /tmp/smtlib3cee8b.smt
Executing: wine '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' '-smt' 'Z: mp\smtlib3cee8b.smt'
wine: cannot find ''/home/chris/.wine/drive_c/Program'
Note that:
- The path to the executable file is chopped off in the first space, even if it is single.
- The literal "\ t" in the last path is converted to a tab character.
Obviously, quotes are not parsed as I expected by the shell. How to avoid these errors?
EDIT: "\ t" expands through two levels of indirection: first, "$p"(and / or "$ARGS") expands to Z:\tmp\smtlib3cee8b.smt; It \texpands to a tab character. This is (similar) equivalent
Y='y\ty'
Z="z${Y}z"
echo $Z
what gives
zy\tyz
but not
zy yz
UPDATE: eval "$CMD" . "\t", -, : " -n, - (" \ "), ". ( POSIX echo)