#!/bin/sh
# This is a wrapper script for LyX/Cygwin to let LyX use the native
# Windows' version of convert which is part of ImageMagick.
#
# This script simply changes all Cygwin pathnames into Windows pathnames.
# If the pathnames contain spaces, either enclose them in double quotes
# or escape the spaces. For example:
# convert "eps:/path with/spaces.pdf" "png:file with spaces.eps"
# convert eps:/path\ with/spaces.pdf png:file\ with\ spaces.eps
#
# 2006-02-13 Enrico Forestieri
# =======================================================================

# The program to call (This should be in the PATH)
# Warning: if ImageMagick isn't installed, the Windows'
# file system convert utility will be called!
prog=convert.exe

while [ $# -gt 0 ] ; do
    case "$1" in
	?:*)  prog="$prog '`cygpath -m -- "$1"`'"
	      ;;
	*:*)  fmt=`echo "$1" | cut -d: -f1`
	      file=`echo "$1" | cut -d: -f2-`
	      file=`cygpath -m -- "$file"`
	      prog="$prog '$fmt:$file'"
	      ;;
	-*)   prog="$prog $1"
	      ;;
	*)    prog="$prog '`cygpath -m -- "$1"`'"
	      ;;
    esac
    shift
done

eval "exec $prog"
