local/bin/wine.sh

   1 #!/bin/bash
   2 
   3 exe="$(locate --regex "$1\$" | head -n 1)"
   4 dir=$exe
   5 arg=
   6 
   7 for i in "${@:2}"; do
   8     [[ $i == ${i/\//} ]] && i=$PWD/$i
   9     arg+='"z:'${i//\//\\}'" '
  10 done
  11 
  12 while [[ $dir != / ]]; do
  13     [[ -d $dir/.wine ]] &&
  14     export WINEPREFIX=$dir/.wine &&
  15     break
  16     dir=$(dirname "$dir")
  17 done
  18 
  19 wine start /unix "$exe" $arg
  20