2017-09-24 09:54:55 +00:00
|
|
|
#!/bin/bash
|
2019-01-05 23:22:21 +00:00
|
|
|
|
|
|
|
# \author Stephan Witt
|
|
|
|
# Full author contact details are available in file CREDITS.
|
|
|
|
|
2017-09-24 09:54:55 +00:00
|
|
|
unset DISPLAY
|
2019-01-05 23:22:21 +00:00
|
|
|
|
|
|
|
# check for file arguments with relative path names
|
|
|
|
# convert them to absolute path names
|
|
|
|
# inkscape on Mac changes the working directory
|
|
|
|
# this invalidates relative path names
|
|
|
|
startinkscape() {
|
|
|
|
inkscape="$1" ; shift
|
|
|
|
pwd=$(pwd)
|
|
|
|
iparams=( "$@" )
|
|
|
|
oparams=()
|
|
|
|
for i in ${!iparams[@]}; do
|
|
|
|
# echo $i "=>" "${iparams[$i]}"
|
|
|
|
case "${iparams[$i]}" in
|
|
|
|
--file=/*|--export-pdf=/*|--export-eps=/*|--export-png=/*|--export-emf=/*|--export-wmf=/*|--export-ps=/*|--export-ps-level=/*|--export-pdf-version=/*)
|
|
|
|
oparams+=( "${iparams[$i]}" )
|
|
|
|
;;
|
|
|
|
--file=*|--export-pdf=*|--export-eps=*|--export-png=*|--export-emf=*|--export-wmf=*|--export-ps=*|--export-ps-level=*|--export-pdf-version=*)
|
|
|
|
oparams+=( "${iparams[$i]//=/=${pwd}/}" )
|
|
|
|
;;
|
|
|
|
--without-gui|-z)
|
|
|
|
# ignore this argument - its provided below anyway
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
oparams+=( "${iparams[$i]}" )
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
exec "${inkscape}" --without-gui "${oparams[@]}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# try to find the inkscape installation...
|
2017-09-24 09:54:55 +00:00
|
|
|
# at first try the well known location
|
|
|
|
RESDIR="/Applications/Inkscape.app/Contents/Resources"
|
2019-01-05 23:22:21 +00:00
|
|
|
if [ -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape ]; then
|
|
|
|
startinkscape "${RESDIR}"/bin/inkscape "$@"
|
|
|
|
exit 0
|
|
|
|
fi
|
2017-09-24 09:54:55 +00:00
|
|
|
# this failed... so try PATH expansion to start the inkscape shell wrapper
|
|
|
|
IFS=":" read -ra DIRLIST <<< "${PATH}"
|
|
|
|
for BINDIR in "${DIRLIST[@]}" ; do
|
|
|
|
RESDIR=$(dirname "${BINDIR}")
|
2019-01-05 23:22:21 +00:00
|
|
|
if [ -f "${RESDIR}"/bin/inkscape -a -x "${RESDIR}"/bin/inkscape ]; then
|
|
|
|
startinkscape "${RESDIR}"/bin/inkscape "$@"
|
|
|
|
exit 0
|
|
|
|
fi
|
2017-09-24 09:54:55 +00:00
|
|
|
done
|
|
|
|
# report error and exit with failure status
|
|
|
|
exec 1>&2
|
|
|
|
echo Could not find Inkscape binary.
|
|
|
|
exit 1
|