fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / shell / source / unix / misc / open-url.sh
blob98a4d3fe00bc91a99fd1dfb98e0db17a97b29001
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # tries to locate the executable specified
21 # as first parameter in the user's path.
22 which() {
23 if [ ! -z "$1" ]; then
24 for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
25 if [ -x "$i/$1" -a ! -d "$i/$1" ]; then
26 echo "$i/$1"
27 break;
29 done
33 # checks for the original mozilla start script(s)
34 # and restrict the "-remote" semantics to those.
35 run_mozilla() {
36 if file "$1" | grep script > /dev/null && grep NPL "$1" > /dev/null; then
37 "$1" -remote 'ping()' 2>/dev/null >/dev/null
38 if [ $? -eq 2 ]; then
39 "$1" "$2" &
40 else
41 "$1" -remote \
42 "openURL($(printf '%s' "$2" \
43 | sed -e 's/(/%28/g' -e 's/)/%29/g' -e 's/,/%2C/g'),new-window)" &
45 else
46 "$1" "$2" &
50 # special handling for mailto: uris
51 if echo "$1" | grep '^mailto:' > /dev/null; then
52 # check for xdg-email
53 mailer=`which xdg-email`
54 if [ ! -z "$mailer" ]; then
55 $mailer "$1" &
56 exit 0
58 # check $MAILER variable
59 if [ ! -z "$MAILER" ]; then
60 $MAILER "$1" &
61 exit 0
63 # mozilla derivates may need -remote semantics
64 for i in thunderbird mozilla netscape icedove iceape; do
65 mailer=`which $i`
66 if [ ! -z "$mailer" ]; then
67 run_mozilla "$mailer" "$1"
68 exit 0
70 done
71 # handle all non mozilla mail clients below
72 # ..
73 else
74 # check for xdg-open
75 browser=`which xdg-open`
76 if [ ! -z "$browser" ]; then
77 $browser "$1" &
78 exit 0
80 # check $BROWSER variable
81 if [ ! -z "$BROWSER" ]; then
82 $BROWSER "$1" &
83 exit 0
85 # mozilla derivates may need -remote semantics
86 for i in chrome seamonkey firefox iceweasel iceape; do
87 browser=`which $i`
88 if [ ! -z "$browser" ]; then
89 run_mozilla "$browser" "$1"
90 exit 0
92 done
93 # handle all non mozilla browers below
94 # ..
96 exit 1