summaryrefslogtreecommitdiff
path: root/www/ns-remote
diff options
context:
space:
mode:
authorabs <abs@pkgsrc.org>2000-09-01 16:05:19 +0000
committerabs <abs@pkgsrc.org>2000-09-01 16:05:19 +0000
commita4c2ad1f11379a38e332fbced54f77c7aae043d1 (patch)
tree0696709bb9f9057b649641ba6becaadb21475714 /www/ns-remote
parent3e7d8d602f7a806109f62bca19fe56c04c31888d (diff)
downloadpkgsrc-a4c2ad1f11379a38e332fbced54f77c7aae043d1.tar.gz
Extend ns-open for potential replacement of the 'netscape' binary
Update ns-remote to 1.3
Diffstat (limited to 'www/ns-remote')
-rw-r--r--www/ns-remote/Makefile4
-rwxr-xr-xwww/ns-remote/files/ns-open108
2 files changed, 92 insertions, 20 deletions
diff --git a/www/ns-remote/Makefile b/www/ns-remote/Makefile
index 9bce0190087..aad17259992 100644
--- a/www/ns-remote/Makefile
+++ b/www/ns-remote/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.3 2000/08/29 09:04:03 abs Exp $
+# $NetBSD: Makefile,v 1.4 2000/09/01 16:05:19 abs Exp $
DISTNAME= ns-remote
-PKGNAME= ns-remote-1.2
+PKGNAME= ns-remote-1.3
CATEGORIES= www
MASTER_SITES= http://home.netscape.com/newsref/std/
DISTFILES= remote.c vroot.h
diff --git a/www/ns-remote/files/ns-open b/www/ns-remote/files/ns-open
index 29da5282156..ddfdeb8288a 100755
--- a/www/ns-remote/files/ns-open
+++ b/www/ns-remote/files/ns-open
@@ -1,29 +1,101 @@
#!/bin/sh
#
-# $NetBSD: ns-open,v 1.2 2000/08/29 09:04:03 abs Exp $
+# $NetBSD: ns-open,v 1.3 2000/09/01 16:05:20 abs Exp $
#
# Simple script to open a URL in Netscape, starting a new process if necessary
-# If a netscape process is not running will run 'netscape'.
-# If you want this to use a different binary (such as navigator), set
-# the environment variable 'NS_OPEN_MOZILLA'.
+# If a netscape process is not running it will look for a valid netscape
+# binary in the colon separated NETSCAPE_PREFERRED list, which can be
+# overridden by the user in the environment.
-if [ -z "$NS_OPEN_MOZILLA" ]; then
- NS_OPEN_MOZILLA=netscape
+if [ -z "$NETSCAPE_PREFERRED" ]; then
+ NETSCAPE_PREFERRED=communicator:navigator
fi
-if [ -z "$1" ]
-then
- ns-remote -noraise -remote openBrowser
-else
- # encode ',' or '`' to avoid problems with the openURL(x,y) command
- URL=`echo $1 | sed -e 's/,/%2c/g' -e 's/\`/%60/g`
- echo ns-remote -noraise -remote openURL\(${URL}\,new-window\)
-fi
+# Locate appropriate netscape binary and set NETSCAPE_BIN
+# If we cannot locate, do not fail with an error here as we may still be
+# able to use ns-remote to talk to an existing netscape process.
+#
+oldIFS="$IFS"
+IFS="${IFS}:"
+for prog in $NETSCAPE_PREFERRED ; do
+ case $prog in
+ /*) if [ -x $prog ]; then
+ NETSCAPE_BIN=$prog
+ break
+ fi
+ ;;
+ *) for dir in $PATH;do
+ if [ -x $dir/$prog ];then
+ NETSCAPE_BIN=$dir/$prog
+ break
+ fi
+ done
+ ;;
+ esac
+done
+IFS="$oldIFS"
+
+RAISE=-noraise
+# Check if there are any '-' options which would not be understood by ns-remote
+# Slightly involved to avoid changing $@ in case we need it for real netscape
+#
+for a ; do
+ if [ "$SKIP_ARG" = 1 ];then
+ NS_REMOTE_ARGS="$NS_REMOTE_ARGS $a"
+ SKIP_ARG=0
+ continue
+ fi
+ case $a in
+ -display | -id)
+ SKIP_ARG=1
+ ;;
+ -remote)
+ REMOTE_SPECIFIED=1
+ SKIP_ARG=1
+ ;;
+ -raise | -noraise)
+ RAISE=
+ ;;
+ -* )
+ UNRECOGNISED_OPTION=1
+ ;;
+ *)
+ URL=`echo $a | sed -e 's/"/%22/g' -e 's/,/%2c/g' -e 's/\`/%60/g`
+ break;
+ ;;
+ esac
+ NS_REMOTE_ARGS="$NS_REMOTE_ARGS $a"
+done
-if [ $? -ne 0 ]
-then
- echo "Starting new Netscape process..."
- $NS_OPEN_MOZILLA $1 &
+# If we recognised all the options, try ns-remote
+#
+if [ -z "$UNRECOGNISED_OPTION" ];then
+ NS_REMOTE_ARGS="$NS_REMOTE_ARGS $RAISE"
+ if [ -z "$REMOTE_SPECIFIED" ];then
+ if [ -n "$URL" ];then
+ # encode , " and ` to avoid problems with openURL(x,y)
+ NS_REMOTE_ARGS="$NS_REMOTE_ARGS -remote openURL(${URL},new-window)"
+ else
+ NS_REMOTE_ARGS="$NS_REMOTE_ARGS -remote openBrowser"
+ fi
+ fi
+ if ns-remote $NS_REMOTE_ARGS ; then
+ exit 0
+ fi
fi
+if [ -z "$NETSCAPE_BIN" ];then
+ echo "Unable to locate netscape binary '$NETSCAPE_PREFERRED'"
+ exit 1
+fi
+case $1 in
+ -*)
+ $NETSCAPE_BIN $@
+ ;;
+ *)
+ # Since using ns-remote will return, we start netscape in the
+ # background to give consistent behaviour.
+ $NETSCAPE_BIN $@ &
+ ;;
+esac
exit 0