#!/bin/bash

XMESSAGE=/usr/bin/xmessage
ARCH="`dpkg --print-architecture`"

# Give a warning if launched from mailcap
if [ `basename $0` = "wine-safe" ]; then
 $XMESSAGE -center \
 -title "Launching Wine" \
 -default "No" \
 -buttons "No":0,"Yes":2 \
 "
 Wine will launch to run the requested Windows executable.
 To protect you from accidentally running a Windows virus,
 you must confirm that this is what you intended to do.
 " 2>/dev/null
 safe_launch=$?
 if [ $safe_launch -eq 0 ] ; then
  exit 1
 fi
 if [ $safe_launch -eq 1 ] ; then
  # xmessage was unable to ask the user, try tty instead
  echo "Wine will launch to run the requested Windows executable." >&2
  echo "To protect you from accidentally running a Windows virus," >&2
  echo "you must confirm that this is what you intended to do." >&2
  echo -n "(yes/no) " >&2
  read safe_confirm
  if [ "$safe_confirm" != 'yes' -a "$safe_confirm" != 'y' ] ; then
   exit 1
  fi
 fi
fi

# Launch Wine
export WINELOADER="/usr/lib/i386-linux-gnu/wine/wine.bin"
exec "$WINELOADER" "$@"
