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_CONFIG_FILE" ]; then
36 GNUSTEP_CONFIG_FILE=@GNUSTEP_CONFIG_FILE@
38 . $GNUSTEP_CONFIG_FILE
40 . $GNUSTEP_SYSTEM_ROOT/Library/Makefiles/GNUstep.sh
42 if [ -z "$GNUSTEP_FLATTENED" ]; then
43 GNUSTEP_FLATTENED=@GNUSTEP_FLATTENED@
48 # TODO: implement a --library-combo parameter
51 echo usage: openapp [--find] application [arguments...]
53 echo application is the complete or relative name of the application
54 echo program with or without the .app extension, like Ink.app.
56 echo [arguments...] are the arguments to the application.
58 echo If --find is used as first argument, openapp prints out
59 echo the full path of the application executable which would be
60 echo executed, without actually executing it as it would normally do.
67 echo Missing application name. Please try openapp --help for more help.
70 app="$2"; shift; shift;;
75 # Remove leading slashes at the end of the application name
76 app="`echo \"$app\" | sed 's%/*$%%'`"
78 # Now form the set of directory names we look for. If the user has
79 # given us a full application directory name (for example, Gorm.app)
80 # then we only search for the given directory name; if instead the
81 # user has given us the application name without the suffix (for
82 # example, 'Gorm') we want to search for Gorm.app, then for
83 # Gorm.debug, then for Gorm.profile (in that order).
84 # If the appname is known, save it to avoid running a grep later to get it.
86 *.app) a1="$app"; a2=""; a3=""; appname="";;
87 *.debug) a1="$app"; a2=""; a3=""; appname="";;
88 *.profile) a1="$app"; a2=""; a3=""; appname="";;
89 *) a1="$app.app"; a2="$app.debug" a3="$app.profile"; appname="$app";
93 /*) # An absolute path.
94 for appdir in "$a1" "$a2" "$a3"; do
95 if [ \( "" != "$appdir" \) -a \( -d "$appdir" \) ]; then
96 full_appname="$appdir"
101 */*) # A relative path
102 for appdir in "$a1" "$a2" "$a3"; do
103 if [ \( "" != "$appdir" \) -a \( -d "$appdir" \) ]; then
104 full_appname="`(cd \"$appdir\"; pwd)`"
110 # We should first search the standard GNUstep locations.
111 for dir in "$GNUSTEP_USER_ROOT" "$GNUSTEP_LOCAL_ROOT" "$GNUSTEP_NETWORK_ROOT" "$GNUSTEP_SYSTEM_ROOT"; do
112 for appdir in "$a1" "$a2" "$a3"; do
113 # Standard locations ... in $dir/Applications/$appdir
114 if [ \( "" != "$appdir" \) -a \( -d "$dir/Applications/$appdir" \) ]; then
115 full_appname="`(cd \"$dir/Applications/$appdir\"; pwd)`"
120 if [ -z "$full_appname" ]; then
121 # And now search the standard PATH (may include '.')
125 for appdir in "$a1" "$a2" "$a3"; do
126 if [ \( "" != "$appdir" \) -a \( -d "$dir/$appdir" \) ]; then
127 full_appname="`(cd \"$dir/$appdir\"; pwd)`"
139 if [ -z "$full_appname" ]; then
140 echo "Can't find the required application: $app!"
144 #echo "found: $full_appname"
147 if [ -z "$appname" ]; then
148 appname="`echo \"$app\" | sed 's/\.[a-z]*$//'`"
150 appname="`basename \"$appname\"`"
152 if [ -n "$GNUSTEP_FLATTENED" ]; then
154 if [ -z "$EXEEXT" ]; then
158 if [ -n "$EXEEXT" ]; then
159 appname="$appname$EXEEXT"
164 case "$LIBRARY_COMBO" in
165 apple-*) app_executable="$full_appname/Contents/MacOS/$appname";;
166 *) app_executable="$full_appname/$appname";;
169 if [ ! -f "$app_executable" ]; then
170 echo "Could not find $app_executable executable/script"
174 if [ -n "$only_find" ]; then
175 echo "$app_executable"
179 exec "$app_executable" "$@"