#!/bin/sh
#100411 fix for spaces in path/filename.

#Puppy does not want more than one instance of Moz running.

#aug06:
#note, must execute mozilla-bin here, as it is a script with
# a bug fix, and then executes seamonkey-bin.

COMTAIL="$@"

[ "$COMTAIL" = "" ] && exec mozilla #v3.94

URLPREFIX="`echo "$COMTAIL" | grep -E "http://|ftp://|https://|file://|-mail|-edit|-addressbook|-calendar|-remote"`"
if [ "$URLPREFIX" = "" ];then
 COMTAIL="`echo -n "$COMTAIL" | sed -e 's/ /%20/g'`"
 COMTAIL="file://${COMTAIL}"
else
 URLPREFIX="`echo "$COMTAIL" | grep "^file://"`"
 [ "$URLPREFIX" ] && COMTAIL="`echo -n "$COMTAIL" | sed -e 's/ /%20/g'`"
fi

ps | grep --extended-regexp 'mozilla\-bin|seamonkey\-bin' > /dev/null 2>&1
if [ $? -eq 0 ];then #=0 if found.
 #exec /usr/lib/mozilla/mozilla-bin -remote "openURL($COMTAIL,new-tab)"
 exec mozilla -remote "openURL($COMTAIL,new-tab)"
else
 #exec /usr/lib/mozilla/mozilla-bin $COMTAIL
 exec mozilla $COMTAIL
fi
