2000-06-13 15:14:23 +00:00
|
|
|
#!/bin/sh
|
1997-10-13 23:30:17 +00:00
|
|
|
#
|
2002-05-02 15:07:49 +00:00
|
|
|
# @configure_input@
|
|
|
|
#
|
1997-10-13 23:30:17 +00:00
|
|
|
# Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# Author: Ovidiu Predescu <ovidiu@net-community.com>
|
|
|
|
# Date: October 1997
|
2002-09-12 08:48:46 +00:00
|
|
|
# Author: Nicola Pero <n.pero@mi.flashnet.it>
|
|
|
|
# Date: 2002
|
|
|
|
#
|
1997-10-13 23:30:17 +00:00
|
|
|
# This file is part of the GNUstep Makefile Package.
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public
|
|
|
|
# License along with this library; see the file COPYING.LIB.
|
|
|
|
# If not, write to the Free Software Foundation,
|
2005-05-22 03:20:14 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1997-10-13 23:30:17 +00:00
|
|
|
|
|
|
|
# Try to execute the application passed as argument. The application is
|
|
|
|
# searched through the GNUstep directories if a complete or relative path name
|
1997-10-14 18:46:16 +00:00
|
|
|
# is not specified. The arguments passed after the application name are passed
|
|
|
|
# unmodified to the application.
|
1997-10-13 23:30:17 +00:00
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2003-01-31 00:40:11 +00:00
|
|
|
echo usage: openapp [--find] application [arguments...]
|
|
|
|
echo openapp --help for more help
|
1997-10-13 23:30:17 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2000-12-06 06:48:04 +00:00
|
|
|
if [ -z "$GNUSTEP_FLATTENED" ]; then
|
|
|
|
GNUSTEP_FLATTENED=@GNUSTEP_FLATTENED@
|
|
|
|
fi
|
1997-10-13 23:30:17 +00:00
|
|
|
|
2003-01-31 00:40:11 +00:00
|
|
|
only_find=
|
|
|
|
|
|
|
|
# TODO: implement a --library-combo parameter
|
2002-09-12 08:28:28 +00:00
|
|
|
case "$1" in
|
1999-02-18 06:22:33 +00:00
|
|
|
--help)
|
2003-01-31 00:40:11 +00:00
|
|
|
echo usage: openapp [--find] application [arguments...]
|
1999-02-18 06:22:33 +00:00
|
|
|
echo
|
|
|
|
echo application is the complete or relative name of the application
|
2003-01-31 00:40:11 +00:00
|
|
|
echo program with or without the .app extension, like Ink.app.
|
1999-02-18 06:22:33 +00:00
|
|
|
echo
|
2001-04-13 19:49:16 +00:00
|
|
|
echo [arguments...] are the arguments to the application.
|
2003-01-31 00:40:11 +00:00
|
|
|
echo
|
|
|
|
echo If --find is used as first argument, openapp prints out
|
|
|
|
echo the full path of the application executable which would be
|
|
|
|
echo executed, without actually executing it as it would normally do.
|
|
|
|
echo
|
1999-02-18 06:22:33 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
2003-01-31 00:40:11 +00:00
|
|
|
--find)
|
|
|
|
only_find=yes;
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo Missing application name. Please try openapp --help for more help.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
app="$2"; shift; shift;;
|
1997-10-14 18:46:16 +00:00
|
|
|
*)
|
2002-09-12 08:28:28 +00:00
|
|
|
app="$1"; shift;;
|
1997-10-14 18:46:16 +00:00
|
|
|
esac
|
1997-10-13 23:30:17 +00:00
|
|
|
|
1997-10-15 22:45:58 +00:00
|
|
|
# Remove leading slashes at the end of the application name
|
2003-05-14 15:10:22 +00:00
|
|
|
app="`echo \"$app\" | sed 's%/*$%%'`"
|
1997-10-15 22:45:58 +00:00
|
|
|
|
2002-09-12 08:28:28 +00:00
|
|
|
# Now build the list of directory names we look for. If the user has
|
|
|
|
# given us a full application directory name (for example, Gorm.app)
|
|
|
|
# then we only search for the given directory name; if instead the
|
|
|
|
# user has given us the application name without the suffix (for
|
|
|
|
# example, 'Gorm') we want to search for Gorm.app, then for
|
|
|
|
# Gorm.debug, then for Gorm.profile (in that order).
|
|
|
|
# If the appname is known, save it to avoid running a grep later to get it.
|
|
|
|
case "$app" in
|
|
|
|
*.app) app_list="$app"; appname="";;
|
|
|
|
*.debug) app_list="$app"; appname="";;
|
|
|
|
*.profile) app_list="$app"; appname="";;
|
|
|
|
*) app_list="$app.app:$app.debug:$app.profile"; appname="$app";
|
|
|
|
esac
|
|
|
|
|
|
|
|
old_IFS="$IFS"
|
|
|
|
IFS=:
|
|
|
|
case "$app" in
|
|
|
|
/*) # An absolute path.
|
|
|
|
for appdir in $app_list; do
|
|
|
|
#echo "$appdir"
|
|
|
|
if [ -d "$appdir" ]; then
|
|
|
|
full_appname="$appdir"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done;;
|
|
|
|
*/*) # A relative path
|
|
|
|
for appdir in $app_list; do
|
|
|
|
#echo "$appdir"
|
|
|
|
if [ -d "$appdir" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
full_appname="`(cd \"$appdir\"; pwd)`"
|
2002-09-12 08:28:28 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done;;
|
|
|
|
*) # A path that should be searched into the GNUstep paths
|
|
|
|
if [ -n "$GNUSTEP_PATHLIST" ]; then
|
|
|
|
SPATH="$GNUSTEP_PATHLIST"
|
|
|
|
else
|
|
|
|
SPATH="$PATH"
|
|
|
|
fi
|
|
|
|
SPATH=".:$SPATH"
|
|
|
|
|
|
|
|
for dir in $SPATH; do
|
|
|
|
for appdir in $app_list; do
|
|
|
|
# First, search in $dir/Applications/any_path_here/$appdir
|
|
|
|
#echo "$dir/Applications/"'*'"/$appdir"
|
|
|
|
for d in $dir/Applications/*/$appdir ; do
|
|
|
|
# If nothing is found, * expands to '*'. Check that it's
|
|
|
|
# not the case, and that we have a real match.
|
|
|
|
if [ "$d" != "$dir/Applications/"'*'"/$appdir" ]; then
|
|
|
|
#echo " $d"
|
|
|
|
if [ -d "$d" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
full_appname="`(cd \"$d\"; pwd)`"
|
2002-09-12 08:28:28 +00:00
|
|
|
break 3
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# Now, in $dir/Applications/$appdir
|
|
|
|
#echo "$dir/Applications/$appdir"
|
|
|
|
if [ -d "$dir/Applications/$appdir" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
full_appname="`(cd \"$dir/Applications/$appdir\"; pwd)`"
|
2002-09-12 08:28:28 +00:00
|
|
|
break 2
|
1997-10-13 23:30:17 +00:00
|
|
|
fi
|
2002-09-12 08:28:28 +00:00
|
|
|
# Finally, in $dir/$appdir
|
|
|
|
#echo "$dir/$appdir"
|
|
|
|
if [ -d "$dir/$appdir" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
full_appname="`(cd \"$dir/$appdir\"; pwd)`"
|
2002-09-12 08:28:28 +00:00
|
|
|
break 2
|
1999-06-11 21:10:35 +00:00
|
|
|
fi
|
2002-09-12 08:28:28 +00:00
|
|
|
done
|
|
|
|
done;;
|
1997-10-13 23:30:17 +00:00
|
|
|
esac
|
2002-09-12 08:28:28 +00:00
|
|
|
IFS="$old_IFS"
|
|
|
|
unset app_list
|
|
|
|
unset appdir
|
1997-10-13 23:30:17 +00:00
|
|
|
|
1997-10-14 22:54:35 +00:00
|
|
|
if [ -z "$full_appname" ]; then
|
|
|
|
echo "Can't find the required application: $app!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2002-09-12 08:28:28 +00:00
|
|
|
#echo "found: $full_appname"
|
|
|
|
|
1999-02-18 06:22:33 +00:00
|
|
|
# get base app name
|
2002-09-12 08:28:28 +00:00
|
|
|
if [ -z "$appname" ]; then
|
2003-05-14 15:10:22 +00:00
|
|
|
appname="`echo \"$app\" | sed 's/\.[a-z]*$//'`"
|
2002-10-04 22:31:07 +00:00
|
|
|
fi
|
2003-05-14 15:10:22 +00:00
|
|
|
appname="`basename \"$appname\"`"
|
1999-02-18 06:22:33 +00:00
|
|
|
|
2002-03-26 17:36:31 +00:00
|
|
|
if [ -n "$GNUSTEP_FLATTENED" ]; then
|
|
|
|
|
|
|
|
if [ -z "$EXEEXT" ]; then
|
|
|
|
EXEEXT=@EXEEXT@
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$EXEEXT" ]; then
|
|
|
|
appname="$appname$EXEEXT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
case "$LIBRARY_COMBO" in
|
|
|
|
apple-*) app_executable="$full_appname/Contents/MacOS/$appname";;
|
|
|
|
*) app_executable="$full_appname/$appname";;
|
|
|
|
esac
|
2002-03-26 17:36:31 +00:00
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
if [ ! -f "$app_executable" ]; then
|
|
|
|
echo "Could not find $app_executable executable/script"
|
2001-04-13 19:49:16 +00:00
|
|
|
exit 1
|
1997-10-13 23:30:17 +00:00
|
|
|
fi
|
2000-12-06 06:48:04 +00:00
|
|
|
|
2003-01-31 00:40:11 +00:00
|
|
|
if [ -n "$only_find" ]; then
|
2004-03-08 14:02:12 +00:00
|
|
|
echo "$app_executable"
|
2003-01-31 00:40:11 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2004-03-08 14:02:12 +00:00
|
|
|
exec "$app_executable" "$@"
|