5 # Copyright (C) 1997 Free Software Foundation, Inc.
7 # Author: Ovidiu Predescu <ovidiu@net-community.com>
9 # Author: Nicola Pero <n.pero@mi.flashnet.it>
12 # This file is part of the GNUstep Makefile Package.
14 # This library is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
19 # You should have received a copy of the GNU General Public
20 # License along with this library; see the file COPYING.LIB.
21 # If not, write to the Free Software Foundation,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 # Try to execute the application passed as argument. The application is
25 # searched through the GNUstep directories if a complete or relative path name
26 # is not specified. The arguments passed after the application name are passed
27 # unmodified to the application.
30 echo usage: openapp [--find] application [arguments...]
31 echo openapp --help for more help
35 if [ -z "$GNUSTEP_FLATTENED" ]; then
36 GNUSTEP_FLATTENED=@GNUSTEP_FLATTENED@
41 # TODO: implement a --library-combo parameter
44 echo usage: openapp [--find] application [arguments...]
46 echo application is the complete or relative name of the application
47 echo program with or without the .app extension, like Ink.app.
49 echo [arguments...] are the arguments to the application.
51 echo If --find is used as first argument, openapp prints out
52 echo the full path of the application executable which would be
53 echo executed, without actually executing it as it would normally do.
60 echo Missing application name. Please try openapp --help for more help.
63 app="$2"; shift; shift;;
68 # Remove leading slashes at the end of the application name
69 app="`echo \"$app\" | sed 's%/*$%%'`"
71 # Now build the list of directory names we look for. If the user has
72 # given us a full application directory name (for example, Gorm.app)
73 # then we only search for the given directory name; if instead the
74 # user has given us the application name without the suffix (for
75 # example, 'Gorm') we want to search for Gorm.app, then for
76 # Gorm.debug, then for Gorm.profile (in that order).
77 # If the appname is known, save it to avoid running a grep later to get it.
79 *.app) app_list="$app"; appname="";;
80 *.debug) app_list="$app"; appname="";;
81 *.profile) app_list="$app"; appname="";;
82 *) app_list="$app.app:$app.debug:$app.profile"; appname="$app";
88 /*) # An absolute path.
89 for appdir in $app_list; do
91 if [ -d "$appdir" ]; then
92 full_appname="$appdir"
96 */*) # A relative path
97 for appdir in $app_list; do
99 if [ -d "$appdir" ]; then
100 full_appname="`(cd \"$appdir\"; pwd)`"
104 *) # A path that should be searched into the GNUstep paths
105 if [ -n "$GNUSTEP_PATHLIST" ]; then
106 SPATH="$GNUSTEP_PATHLIST"
112 for dir in $SPATH; do
113 for appdir in $app_list; do
114 # First, search in $dir/Applications/any_path_here/$appdir
115 #echo "$dir/Applications/"'*'"/$appdir"
116 for d in $dir/Applications/*/$appdir ; do
117 # If nothing is found, * expands to '*'. Check that it's
118 # not the case, and that we have a real match.
119 if [ "$d" != "$dir/Applications/"'*'"/$appdir" ]; then
122 full_appname="`(cd \"$d\"; pwd)`"
127 # Now, in $dir/Applications/$appdir
128 #echo "$dir/Applications/$appdir"
129 if [ -d "$dir/Applications/$appdir" ]; then
130 full_appname="`(cd \"$dir/Applications/$appdir\"; pwd)`"
133 # Finally, in $dir/$appdir
135 if [ -d "$dir/$appdir" ]; then
136 full_appname="`(cd \"$dir/$appdir\"; pwd)`"
146 if [ -z "$full_appname" ]; then
147 echo "Can't find the required application: $app!"
151 #echo "found: $full_appname"
154 if [ -z "$appname" ]; then
155 appname="`echo \"$app\" | sed 's/\.[a-z]*$//'`"
157 appname="`basename \"$appname\"`"
159 if [ -n "$GNUSTEP_FLATTENED" ]; then
161 if [ -z "$EXEEXT" ]; then
165 if [ -n "$EXEEXT" ]; then
166 appname="$appname$EXEEXT"
171 case "$LIBRARY_COMBO" in
172 apple-*) app_executable="$full_appname/Contents/MacOS/$appname";;
173 *) app_executable="$full_appname/$appname";;
176 if [ ! -f "$app_executable" ]; then
177 echo "Could not find $app_executable executable/script"
181 if [ -n "$only_find" ]; then
182 echo "$app_executable"
186 exec "$app_executable" "$@"