]> git.lyx.org Git - lyx.git/blob - development/MacOSX/lyxeditor
installer updates
[lyx.git] / development / MacOSX / lyxeditor
1 #!/bin/sh
2 # ron@18james.com, 11 Dec 2003
3 # With modifications by Angus Leeming, tweaked by Bennett Helm 21 Jan 2007
4
5 parse_serverpipe()
6 {
7         test -r "$1" || {
8                 echo "Usage: parse_serverpipe lyxrc" >&2
9                 exit 1
10         }
11
12         # The output of this sed script is output to STDOUT
13         LYXPIPE=`sed -n '/^\\\\serverpipe /{
14 # First consider that the file path may be quoted
15 s/^ *\\\\serverpipe \{1,\}\"\([^"]\{1,\}\)\" *$/\1/
16 tfound
17
18 # Now, unquoted
19 s/^ *\\\\serverpipe \{1,\}\(.*\)/\1/
20 s/ *$//
21
22 :found
23 # Change from single to double shell quoting temporarily...
24 '"
25 s@^~/@${HOME}/@
26 # Revert to single shell quotes
27 "'
28
29 p
30 q
31 }' "$1"`
32
33         echo "${LYXPIPE}"
34         unset LYXPIPE
35 }
36
37
38 USER_SUPPORT="${HOME}/Library/Application Support"
39 test -d "${USER_SUPPORT}" || {
40         echo "Something horrible is going on. No user support directory $ {USER_SUPPORT}" >&2 
41         exit 1
42 }
43
44 for LYXDIR in LyX-1.5 LyX-1.4 LyX
45 do
46         ABS_USER_LYXDIR="${USER_SUPPORT}/${LYXDIR}"
47         test -d "${ABS_USER_LYXDIR}" || {
48                 echo "Failed to find ABS_USER_LYXDIR: ${ABS_USER_LYXDIR}" >&2
49                 continue
50         }
51         PREFERENCES="${ABS_USER_LYXDIR}/preferences"
52         test -r "${PREFERENCES}" || {
53                 echo "Failed to find PREFERENCES: ${PREFERENCES}" >&2
54                 continue
55         }
56         # preferences file exists.
57         # See if it contains a \\serverpipe entry
58         # Whether it does or not, break out of the loop because we've
59         # found the preferences file.
60         LYXPIPE=`parse_serverpipe "${PREFERENCES}"`
61         break
62 done
63
64 echo "preferences file sets lyxpipe as ${LYXPIPE}"
65
66 test -z "${LYXPIPE}" && {
67         ABS_SYSTEM_LYXDIR='/Applications/LyX.app/Contents/Resources'
68         test -d "${ABS_SYSTEM_LYXDIR}" || {
69                 echo "Failed to find ABS_SYSTEM_LYXDIR: ${ABS_SYSTEM_LYXDIR}" >&2
70                 exit 1
71         }
72         LYXRC_DIST="${ABS_SYSTEM_LYXDIR}/lyxrc.dist"
73         test -r "${LYXRC_DIST}" || {
74                 echo "Failed to find LYXRC_DIST: ${LYXRC_DIST}" >&2
75                 exit 1
76         }
77
78         # lyxrc.dist exists
79         # See if it contains a \\serverpipe entry
80         LYXPIPE=`parse_serverpipe "${LYXRC_DIST}"`
81 }
82
83 echo "Our best guess sets lyxpipe as ${LYXPIPE}"
84
85 # The end
86
87 file=`echo "$1" | sed 's|^/private||'`
88
89 MAC_LYXPIPE_CONTENTS="LYXCMD:macdvix:server-goto-file-row:$file $2"
90 echo "$MAC_LYXPIPE_CONTENTS"
91 echo "$MAC_LYXPIPE_CONTENTS" > "${LYXPIPE}".in || exit
92 read < "${LYXPIPE}".out || exit