+USER_SUPPORT="${HOME}/Library/Application Support"
+test -d "${USER_SUPPORT}" || {
+ echo "Something horrible is going on. No user support directory $ {USER_SUPPORT}" >&2
+ exit 1
+}
+
+for LYXDIR in LyX-1.5 LyX-1.4 LyX
+do
+ ABS_USER_LYXDIR="${USER_SUPPORT}/${LYXDIR}"
+ test -d "${ABS_USER_LYXDIR}" || {
+ echo "Failed to find ABS_USER_LYXDIR: ${ABS_USER_LYXDIR}" >&2
+ continue
+ }
+ PREFERENCES="${ABS_USER_LYXDIR}/preferences"
+ test -r "${PREFERENCES}" || {
+ echo "Failed to find PREFERENCES: ${PREFERENCES}" >&2
+ continue
+ }
+ # preferences file exists.
+ # See if it contains a \\serverpipe entry
+ # Whether it does or not, break out of the loop because we've
+ # found the preferences file.
+ LYXPIPE=`parse_serverpipe "${PREFERENCES}"`
+ break
+done
+
+echo "preferences file sets lyxpipe as ${LYXPIPE}"
+
+test -z "${LYXPIPE}" && {
+ ABS_SYSTEM_LYXDIR='/Applications/LyX.app/Contents/Resources'
+ test -d "${ABS_SYSTEM_LYXDIR}" || {
+ echo "Failed to find ABS_SYSTEM_LYXDIR: ${ABS_SYSTEM_LYXDIR}" >&2
+ exit 1
+ }
+ LYXRC_DIST="${ABS_SYSTEM_LYXDIR}/lyxrc.dist"
+ test -r "${LYXRC_DIST}" || {
+ echo "Failed to find LYXRC_DIST: ${LYXRC_DIST}" >&2
+ exit 1
+ }
+
+ # lyxrc.dist exists
+ # See if it contains a \\serverpipe entry
+ LYXPIPE=`parse_serverpipe "${LYXRC_DIST}"`
+}
+
+echo "Our best guess sets lyxpipe as ${LYXPIPE}"
+
+# The end
+
+file=`echo "$1" | sed 's|^/private||'`