Procrastiblog

September 2, 2008

WINE Paths

Filed under: Linux — Chris @ 11:02 pm

If you try to run a Windows command-line app on Linux under WINE, you may find that filename arguments yield errors like the following:

$ wine z3.exe -smt /tmp/smtlib2b129a.smt

Error: invalid command line option: /tmp/smtlib2b129a.smt
For usage information: z3 /h

The problem here is that the ‘/’ at the beginning of an absolute path can be interpreted as the beginning of a Windows-style command-line argument. The following script takes a Windows command-line and Windows-ifies Unix path arguments.

#! /bin/bash

if [ "${1+set}" != "set" ]
then
  echo "Usage; winewrap EXEC [ARGS...]"
  exit 1
fi

EXEC="$1"
shift

for p in "$@";
do
  if [ -e "$p" ];
  then
    p=$(winepath -w "$p")
  fi
  ARGS="$ARGS $p"
done

wine "$EXEC" $ARGS

The script can be used thus:

$ winewrap z3.exe -smt /tmp/smtlib2b129a.smt

Which will execute

wine z3.exe -smt Z:\tmp\smtlib2b129a.smt

P.S. You can also just use the WINE drive mapping (in this case / == Z:\), but I’d rather keep my Unix mindset and let the script do the work.

Advertisements

Blog at WordPress.com.

%d bloggers like this: