--- mozilla/build/unix/run-mozilla.sh.fix 2003-12-15 20:27:28 +0300 +++ mozilla/build/unix/run-mozilla.sh 2005-06-28 22:24:43 +0400 @@ -64,16 +64,21 @@ ## # cmdname=`basename "$0"` MOZ_DIST_BIN=`dirname "$0"` MOZ_DEFAULT_NAME="./${cmdname}-bin" MOZ_APPRUNNER_NAME="./mozilla-bin" MOZ_VIEWER_NAME="./viewer" MOZ_PROGRAM="" +MOZ_CLIENT_PROGRAM="${MOZ_DIST_BIN}/mozilla-xremote-client" +MOZ_CLIENT_OPTS=" -a mozilla -u $USER" + +ALREADY_RUNNING="" +RUNS="" exitcode=0 # ## ## Functions ## ########################################################################## moz_usage() @@ -150,53 +155,78 @@ moz_get_debugger() debugger=$dpath break fi done echo $debugger return 0 } ########################################################################## +check_running() { + "$MOZ_CLIENT_PROGRAM" $MOZ_CLIENT_OPTS 'ping()' 2>/dev/null >/dev/null || return 1 +} +########################################################################## +open_mail() { + [ "${ALREADY_RUNNING}" -eq "1" ] || { RUNS="$MOZ_PROGRAM $*"; return 0; } + RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS xfeDoCommand(openInbox)" +} +########################################################################## +open_compose() { + [ "${ALREADY_RUNNING}" -eq "1" ] || { RUNS="$MOZ_PROGRAM $*"; return 0; } + RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS xfeDoCommand(composeMessage)" +} +########################################################################## +open_browser() { + local opt="$1" && shift ||: + [ "${opt#-}" = "$opt" ] || return 0 + [ "${opt#altbug:}" = "$opt" ] || opt="https://bugzilla.altlinux.org/show_bug.cgi?id=${opt#altbug:}" + + if [ "${ALREADY_RUNNING}" -eq "0" ]; then + [ -z "$opt" ] || RUNS="$prog $opt $*" + return 0 + fi + + [ -n "$opt" ] || { RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS xfeDoCommand(openBrowser)"; return 0; } + + # check to make sure that the command contains at least a :/ in it. + if [ "${opt#*:/}" = "$opt" ]; then + # if it doesn't begin with a '/' and it exists when the pwd is + # prepended to it then append the full path + [ "${opt#/}" = "$opt" ] && [ -e "$PWD/$opt" ] && opt="$PWD/$opt" + RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS openurl($opt)" + return 0 + fi + # just pass it off if it looks like a url + RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS openurl($opt)" +} +########################################################################## moz_run_program() { prog=$MOZ_PROGRAM ## ## Make sure the program is executable ## if [ ! -x "$prog" ] then moz_bail "Cannot execute $prog." fi - ## - ## Use md5sum to crc a core file. If md5sum is not found on the system, - ## then dont debug core files. - ## - moz_test_binary /bin/type - if [ $? -eq 1 ] - then - crc_prog=`type md5sum 2>/dev/null | awk '{print $3;}' 2>/dev/null | sed -e 's/\.$//'` + + check_running && ALREADY_RUNNING=1 || ALREADY_RUNNING=0 + RUNS= + + if [ "$1" = "-mail" ]; then + open_mail ${1+"$@"} + elif [ "$1" = "-compose" ]; then + open_compose ${1+"$@"} else - crc_prog=`which md5sum 2>/dev/null` + open_browser $* fi - if [ -x "$crc_prog" ] - then - DEBUG_CORE_FILES=1 - fi - if [ "$DEBUG_CORE_FILES" ] - then - crc_old= - if [ -f core ] - then - crc_old=`$crc_prog core | awk '{print $1;}' ` - fi - fi - ## - ## Run the program - ## - "$prog" ${1+"$@"} + + [ -n "$RUNS" ] || RUNS="$prog ${1+"$@"}" + $RUNS exitcode=$? if [ "$DEBUG_CORE_FILES" ] then if [ -f core ] then crc_new=`$crc_prog core | awk '{print $1;}' ` fi fi