--- 2003-03-08-06/moz Sat Mar 8 06:05:20 2003 +++ latest/moz Fri Mar 14 14:47:48 2003 @@ -1,5 +1,5 @@ #!/bin/sh - ver="0.2.2b+.2003030806" + ver="0.2.2b+.2003031414" copy="2002, 2003" mail="PointedEars@gmx.de" mail_feedback="bug-moz@PointedEars.de" @@ -43,7 +43,7 @@ mail_feedback="bug-moz@PointedEars.de" # * With `-k', first try SIGTERM(15) and if (and only if) this has no effect, # send SIGKILL(9); wait [with `-remote ping()'] for Mozilla to end before # doing anything - # * `-l' lists running `mozilla-bin' processes using `ps'; + # * `-l' lists running `mozilla-bin' processes/threads using `ps'; # Tests for and support of user-oriented `ps' output (`u'), # uses Unix98 options as fallback # * `-m' allows to open new Compose window with predefined `To:' field @@ -57,6 +57,7 @@ mail_feedback="bug-moz@PointedEars.de" # [with `-remote ping()'] before passing on to the second argument # * _XPG=1 for `$( `$command` )' and `$(( `$expression` ))' in `sh' (@IRIX 6.5) # * `--version': Display version information and exit + # * Speed-up Mozilla process start-up by using ping() only for first -remote # * Cosmetics: # - Added status messages # - Bold-formatted title with changed tagline @@ -73,9 +74,10 @@ mail_feedback="bug-moz@PointedEars.de" # # TO DO: # - # * Speed-up Mozilla process start-up by using ping() only for first -remote # * POSIX conform parsing of options and arguments # * `-M': Support other programs similar to Mozilla like Phoenix + # * Cosmetics: + # - More modular code (incomplete) # # ---------------------------------------------------------------------------- @@ -98,7 +100,7 @@ test $LINES -eq 0 && LINES=24 test $COLUMNS -eq 0 && COLUMNS=80 if test "$TERM" != "raw" && stty size > /dev/null 2>&1 ; then - esc=`echo -en "\033"` + esc=`echo -en "\033"` extd="${esc}[1m" warn="${esc}[1;31m" done="${esc}[1;32m" @@ -119,7 +121,7 @@ rc_failed_up="${esc}[1A${rc_failed}" rc_save="${esc}7" rc_restore="${esc}8" else - esc="" + esc="" extd="" warn="" done="" @@ -142,33 +144,33 @@ rc_failed_up="${rc_failed}" fi # check for fold - fold="fold -sw $COLUMNS" - chk=`which fold 2> /dev/null` - test $? -ne 0 && fold="cat" - chk=`echo x | $fold 1> /dev/null` - test -n "$chk" && fold="cat" + fold="fold -sw $COLUMNS" + chk=`which fold 2> /dev/null` + test $? -ne 0 && fold="cat" + chk=`echo x | $fold 1> /dev/null` + test -n "$chk" && fold="cat" # check for fmt - fmt=cat - if [ $COLUMNS -ne 80 ]; then # output is preformatted for 80 cols - chk=`which fmt 2> /dev/null` - if [ $? -ne 0 ]; then - fmt=$fold + fmt=cat + if [ $COLUMNS -ne 80 ]; then # output is preformatted for 80 cols + chk=`which fmt 2> /dev/null` + if [ $? -ne 0 ]; then + fmt=$fold + else + # check for columns + fmt="fmt -$COLUMNS" + chk=`echo x | $fmt 2> /dev/null` + test -z "$chk" && fmt="fmt" + # check for -c|--crown-margin + chk=`echo x | $fmt -c 2> /dev/null` + if [ -n "$chk" ]; then + fmt=$fmt" -c" else - # check for columns - fmt="fmt -$COLUMNS" - chk=`echo x | $fmt 2> /dev/null` - test -z "$chk" && fmt="fmt" - # check for -c|--crown-margin - chk=`echo x | $fmt -c 2> /dev/null` - if [ -n "$chk" ]; then - fmt=$fmt" -c" - else - chk=`echo x | $fmt --crown-margin 2> /dev/null` - test -n "$chk" && fmt=$fmt" --crown-margin" - fi + chk=`echo x | $fmt --crown-margin 2> /dev/null` + test -n "$chk" && fmt=$fmt" --crown-margin" fi fi + fi # L10n lg="" @@ -205,6 +207,18 @@ function msg_failed { fi } + function Title { + echo "\ + ${extd}moz $ver -- "`L "Mozilla process manager" "Manager für \ + Mozilla-Prozesse"`"${norm} + Copyright (C) $copy Thomas Lahn <$mail> + "`L "Distributed under the terms of the" \ + "Veröffentlicht unter den Bedingungen der"`" GNU General Public License (GPL), + "`L "see COPYING file or http://www.fsf.org/copyleft/gpl.html for details." \ + "Details in Datei COPYING oder unter http://www.fsf.org/copyleft/gpl.html" \ + | $fold` + } + function help { echo echo "${extd}`basename "$1"`${norm} @@ -335,7 +349,7 @@ L "\ nicht mehr verfügbar sein." | $fmt echo -n " ${extd}-l${norm}, ${extd}--list${norm} " - L "List running Mozilla processes and exit." \ + L "List running Mozilla processes and threads and exit." \ "Zeigt laufende Mozilla-Prozesse an." | $fold echo -n " ${extd}-f${norm} " @@ -517,47 +531,11 @@ _XPG=1 _XPG=0 } - echo " - ${extd}moz $ver -- "`L "Mozilla process manager" "Manager für \ - Mozilla-Prozesse"`"${norm} - Copyright (C) $copy Thomas Lahn <$mail> - "`L "Distributed under the terms of the" \ - "Veröffentlicht unter den Bedingungen der"`" GNU General Public License (GPL), - "`L "see COPYING file or http://www.fsf.org/copyleft/gpl.html for details." \ - "Details in Datei COPYING oder unter http://www.fsf.org/copyleft/gpl.html" \ - | $fold` - - if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then - help=1; - test -n "$1" && shift - fi - test $help -eq 1 && help "$0" - - echo `L "Send suggestions and bug reports to" \ - "Senden Sie Vorschläge und Fehlerberichte an"`" <$mail_feedback> - " | $fold - - test "$1" = "--version" && exit 0 - test $help -eq 1 && exit 255 - - - # check for term/kill - kill=0 - if [ "$1" = "--term" ] || [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then - kill=1 - if [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then sig=-9; fi - KillMoz - if [ $? -ne 0 ] && [ $sig -eq -9 ]; then KillMoz $sig; fi - shift - test -z "$1" && echo && exit 0 - fi - - # check for list - if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then + function ListMoz { # check for supported `ps' options whoami=`whoami` # BSD style user-oriented - args="u $2 " + args="u $1 " ps $args 1>/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args @@ -597,13 +575,46 @@ if [ "$1" = "--list" ] || [ "$1" = "-l" L "There are no \`mozilla-bin' processes running." \ "Es laufen keine \`mozilla-bin'-Prozesse." | $fold >&2 else - echo `L "Running Mozilla processes" \ - "Laufende Mozilla-Prozesse"`": + echo `L "Running Mozilla processes and threads" \ + "Laufende Mozilla-Prozesse und Threads"`": " | $fold >&2 ps $args 2>/dev/null | head -n 1 echo "$chk" fi echo + } + + + test "$1" != "--version" && echo + Title + + if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then + help=1 + help "$0" + test -n "$1" && shift + fi + + echo `L "Send suggestions and bug reports to" \ + "Senden Sie Vorschläge und Fehlerberichte an"`" <$mail_feedback> + " | $fold + + test "$1" = "--version" && exit 0 + test $help -eq 1 && exit 255 + + # check for term/kill + kill=0 + if [ "$1" = "--term" ] || [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then + kill=1 + if [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then sig=-9; fi + KillMoz + if [ $? -ne 0 ] && [ $sig -eq -9 ]; then KillMoz $sig; fi + shift + test -z "$1" && echo && exit 0 + fi + + # check for list + if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then + ListMoz $2 exit 0 fi