Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | #! /bin/sh |
2 | # | |
3 | #! /bin/sh -x | |
4 | ############################################################################### | |
3abe9331 | 5 | # Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
6 | # All rights reserved. This program and the accompanying materials |
7 | # are made available under the terms of the Eclipse Public License v1.0 | |
8 | # which accompanies this distribution, and is available at | |
9 | # http://www.eclipse.org/legal/epl-v10.html | |
10 | ############################################################################### | |
11 | ||
12 | ############################################################################### | |
13 | # Shell script: ttcn3_help | |
14 | # Part of : TITAN | |
15 | # Purpose : opening help pages | |
16 | # Content : | |
17 | # The followings can be configured | |
18 | # browser: the application which opens the help page | |
19 | # (netscape by default) | |
20 | # browser_options: command line options for the browser | |
21 | # help_format: extension of the help files | |
22 | # help_root: root of the help files | |
23 | # | |
24 | # Return value: 1 on error | |
25 | # 0 on success | |
26 | ############################################################################### | |
27 | ||
28 | # check the number of arguments | |
29 | if test "`expr $# != 1`" = "1" | |
30 | then echo "Error: exactly one argument is expected"; exit 1; | |
31 | fi | |
32 | ||
33 | # check for necessary environment variables | |
34 | if test "${TTCN3_DIR}" = "" | |
35 | then echo "Error: TTCN3_DIR environment variable is not set"; exit 1; | |
36 | fi | |
37 | ||
38 | # file extension for help files | |
39 | help_format=".html"; | |
40 | # path of the help pages | |
41 | help_root="${TTCN3_DIR}/help"; | |
42 | ||
43 | # check for browser | |
44 | if test "${TTCN3_BROWSER}" = "" | |
45 | then browser="netscape"; browser_options="-no-about-splash "; | |
46 | else browser="${TTCN3_BROWSER}"; browser_options=" "; | |
47 | fi | |
48 | ||
49 | # check for already running browsers | |
50 | # Netscape | |
51 | if test "`echo ${browser} | grep netscape`" != "" | |
52 | then { | |
53 | username=`whoami` | |
54 | # avoid listing grep command as well | |
55 | pslist=`/bin/ps -u ${username} -f` | |
56 | if test "`echo ${pslist} | grep netscape`" != "" | |
57 | then browser_options="-remote openURL(file:"; endtag=")" | |
58 | else browser_options="-no-about-splash "; endtag="" | |
59 | fi | |
60 | } | |
61 | # Mozilla | |
62 | elif test "`echo ${browser} | grep mozilla`" != "" | |
63 | then { | |
64 | username=`whoami` | |
65 | # avoid listing grep command as well | |
66 | pslist=`/bin/ps -u ${username}` | |
67 | if test "`echo ${pslist} | grep mozilla`" != "" | |
68 | then browser_options="-remote openURL(file:"; endtag=")" | |
69 | else browser_options="file:"; endtag="" | |
70 | fi | |
71 | } | |
72 | # Opera | |
73 | elif test "`echo ${browser} | grep opera`" != "" | |
74 | then { | |
75 | username=`whoami` | |
76 | # avoid listing grep command as well | |
77 | pslist=`/bin/ps -u ${username} -f` | |
78 | if test "`echo ${pslist} | grep opera`" != "" | |
79 | then browser_options="-remote openURL(file:"; endtag=")" | |
80 | else endtag="" | |
81 | fi | |
82 | } | |
83 | # Lynx should be executed in a new terminal | |
84 | elif test "`echo ${browser} | grep lynx`" != "" | |
85 | then { | |
86 | browser="xterm -e ${browser}" | |
87 | endtag="" | |
88 | } | |
89 | else endtag="" | |
90 | fi | |
91 | ||
92 | #echo "browser=$browser" | |
93 | #echo "options=$browser_options" | |
94 | #echo "endtag =$endtag" | |
95 | ||
96 | # the file tree looks like | |
97 | # $TTCN3_DIR/help/titan_main.html | |
98 | # $TTCN3_DIR/help/titan_index.html | |
99 | # $TTCN3_DIR/help/info/<keyword>.html | |
100 | ||
101 | ##### check if it is a document name ##### | |
102 | if test -f ${help_root}/$1 | |
103 | then exec ${browser} ${browser_options}${help_root}/$1${endtag} | |
104 | elif test -f ${help_root}/info/$1 | |
105 | then exec ${browser} ${browser_options}${help_root}/info/$1${endtag} | |
106 | ||
107 | ##### check if it is the keyword 'main' ##### | |
108 | elif test $1 = "main" | |
109 | then exec ${browser} ${browser_options}${help_root}/titan_main${help_format}${endtag} | |
110 | ||
111 | ##### check if it is a keyword ##### | |
112 | elif test -f ${help_root}/info/$1${help_format} | |
113 | then exec ${browser} ${browser_options}${help_root}/info/$1${help_format}${endtag} | |
114 | ||
115 | # otherwise open the index file | |
116 | else exec ${browser} ${browser_options}${help_root}/titan_index${help_format}${endtag} | |
117 | fi | |
118 |