--- 2003-03-28-23/moz Fri Mar 28 23:14:22 2003 +++ latest/moz Sat Mar 29 13:21:04 2003 @@ -1,5 +1,5 @@ #!/bin/sh - ver="0.2.2b+.2003032823" + ver="0.2.2b+.2003032913" copy="2002, 2003" mail="PointedEars@gmx.de" mail_feedback="bug-moz@PointedEars.de" @@ -76,10 +76,7 @@ mail_feedback="bug-moz@PointedEars.de" # # TO DO (0.2.2 release, scheduled in first week of April 2003) # - # * POSIX conform parsing of options and arguments (incomplete): - # - `-?' may become obsolete as `getopt' doesn't support it - # (seems uncommon anyway, so it shouldn't be a great loss); - # `make-nightly' scripts must be altered to use `--help' instead + # * POSIX conform parsing of options and arguments (incomplete) # * `-M', `--mozilla': Support other programs similar to Mozilla like Phoenix # * `-l -f': Force full output format; ignore if not supported (incomplete) # * `-C', `--command' options to execute arbitrary Mozilla commands @@ -96,11 +93,17 @@ mail_feedback="bug-moz@PointedEars.de" # separate word. The quotes around `$@' are essential! # We need `tmp' as the `eval set --' would nuke the return value of getopt. - tmp=`getopt -o vL:M:klfn:w:t:-m::ic \ - --long verbose,locale:,mozilla:,help,version,term,kill,list,\ + if `getopt -T >/dev/null 2>&1` ; [ $? = 4 ] ; then + echo "Enhanced getopt(1)" + tmp=`getopt -o vL:hVM:klfn:w:t:-m::ic \ + --long verbose,locale:,help,version,mozilla:,term,kill,list,\ full,new:,win:,tab:,mailto::,inbox,compose \ - -n $(basename "$0") -- "$@"` - + -n $(basename "$0") -- "$@"` + else + echo "Old getopt(1)" + tmp=`getopt vL:hVM:klfn:w:t:-m:ic "$@"` + fi + getopt_exit_code=$? if [ $getopt_exit_code -eq 0 ]; then ## getopt returns error code 0 for successful parsing, 1 if @@ -113,6 +116,8 @@ if [ $getopt_exit_code -eq 0 ]; then # remove "--" for i in $tmp; do if [ "$i" != "--" ]; then tmp2="${tmp2} $i"; fi; done eval set -- "$tmp2" + echo $* + #exit 0 else echo "getopt exited: $getopt_exit_code " >&2 @@ -137,7 +142,7 @@ fi test $LINES -eq 0 && LINES=24 test $COLUMNS -eq 0 && COLUMNS=80 - if test "$TERM" != "raw" && stty size > /dev/null 2>&1 ; then + if test "$TERM" != "raw" && stty size >/dev/null 2>&1 ; then esc=`echo -en "\033"` extd="${esc}[1m" warn="${esc}[1;31m" @@ -183,28 +188,28 @@ fi # check for fold fold="fold -sw $COLUMNS" - chk=`which fold 2> /dev/null` + chk=`which fold 2>/dev/null` test $? -ne 0 && fold="cat" - chk=`echo x | $fold 1> /dev/null` + chk=`echo x | $fold 2>/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` + 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` + 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` + 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` + chk=`echo x | $fmt --crown-margin 2>/dev/null` test -n "$chk" && fmt=$fmt" --crown-margin" fi fi @@ -212,8 +217,8 @@ fi # L10n lg="" - test -n "$LANG" && lg=`echo $LANG | sed 's/_.*[.].*//' 2> /dev/null` - test -z "$lg" && lg=`echo $LC_CTYPE | sed 's/_.*//' 2> /dev/null` + test -n "$LANG" && lg=`echo $LANG | sed 's/_.*[.].*//' 2>/dev/null` + test -z "$lg" && lg=`echo $LC_CTYPE | sed 's/_.*//' 2>/dev/null` if [ "$1" = "-L" ] || [ "$1" = "--locale" ]; then shift @@ -260,15 +265,16 @@ details." \ } function help { + future=${extd}`L "For future use" "Für zukünftige Verwendung"`.${norm} echo echo "${extd}`basename "$1"`${norm} - [${extd}-v${norm}] [${extd}-L${norm} LOCALE] [${extd}-M${norm} COMMAND] - [ ( ${extd}-?${norm} | ${extd}--version${norm} | ${extd}--term${norm} | \ - ${extd}--kill${norm} | ${extd}-l${norm} [${extd}-f${norm}] ) ] - [ ( [ ( ${extd}-w${norm} | ${extd}-t${norm} ) ] [URI] [...] | ${extd}-${norm}\ - ) [...] ] - [ ( ${extd}-m${norm} [ADDRESS[,...]] | ${extd}-i${norm} | ${extd}-c${norm} ) \ - [...] ] + [${extd}-v${norm}] [${extd}-L${norm} LOCALE] [( ${extd}-h${norm} \ + | ${extd}-V${norm} )] [${extd}-M${norm} COMMAND] [( ${extd}-T${norm} \ + | ${extd}-k${norm} )] [${extd}-l${norm} [${extd}-f${norm}]] + [( [${extd}-wt${norm}] [URI] [...] | ${extd}-${norm} )] \ + [${extd}-m${norm} [ADDRESS[${extd},${norm}...]]] [${extd}-ic${norm}] \ + [${extd}-C${norm} COMMAND] + [...] " echo -n " ${extd}-v${norm}, ${extd}--verbose${norm} " L "Activate verbose mode. For testing purposes." \ @@ -305,13 +311,18 @@ L "\ angeben, stellen Sie sicher, dass die Umgebungsvariable(n) \`LANG' und/oder \`LC_CTYPE' korrekt gesetzt sind." | $fmt + echo -n " ${extd}-h${norm}, ${extd}--help${norm} " + L "Display this help and exit." "Anzeige dieser Hilfe und beenden." | $fold + + echo -n " ${extd}-V${norm}, ${extd}--version${norm} " + L "Display version information and exit." \ + "Anzeige der Version und beenden." | $fold + echo -n " ${extd}-M${norm}, ${extd}--mozilla${norm} " L "Specifies how to run Mozilla. " \ "Definiert, wie Mozilla gestartet werden soll." | $fold - L "\ - ${extd}For future use.${norm}" \ - "\ - ${extd}Für zukünftige Verwendung.${norm}" | $fmt + echo "\ + $future" | $fmt echo -n " COMMAND " L "The command to run Mozilla. The default is \`mozilla'" \ "Befehl, der benutzt werden soll, um Mozilla zu starten." @@ -331,42 +342,33 @@ befindet, das Programm nicht überprüfen, ob der angegebene Pfad korrekt ist." | $fmt - echo -n " ${extd}-?${norm}, ${extd}--help${norm} " - L "Display this help and exit." "Anzeige dieser Hilfe und beenden." | $fold - - echo -n " ${extd}--version${norm} " - L "Display version information and exit." \ - "Anzeige der Version und beenden." | $fold - # version 0.2.3 proposal # echo " --block Block the shell for the 'mozilla' process, i.e. prevent" # echo " following commands to be executed until Mozilla is \ # quit." - echo -n " ${extd}--term${norm} " + echo -n " ${extd}-T${norm}, ${extd}--term${norm} " L "Terminate all Mozilla processes (first), sending each" \ - "Beendet (zuerst) alle Mozilla-Prozesse, indem" | $fold + "Beendet (zuerst) alle Mozilla-Prozesse, indem jedem" | $fold L "\ of them a SIGTERM(15) signal. Need not to work as a process may refuse to terminate (see \ \`${extd}-k${norm}')." \ "\ - jedem Prozess ein SIGTERM(15)-Signal gesendet wird. - Das muss nicht funktionieren, da ein Prozess das - Beenden verweigern kann (siehe \`${extd}-k${norm}')." \ + Prozess ein SIGTERM(15)-Signal gesendet wird. Das + muss nicht funktionieren, da ein Prozess das Beenden + verweigern kann (siehe \`${extd}-k${norm}')." \ | $fmt L "\ Note that the \`${extd}-t${norm}' option, which was \ - previously short - for \`${extd}--term${norm}', now (for POSIX conformance) \ - refers to - the creation of a new browser tab (see below)." \ + previously used + for this feature, now refers to the creation of a new + browser tab (see below)." \ "\ - Hinweis: Die Option \`${extd}-t${norm}' war vorher die \ - Kurzform für - \`${extd}--term${norm}', bedeutet aber jetzt \ - (POSIX-konform), dass - ein neuer Browser-Tab erzeugt wird (siehe unten)." | $fmt + Hinweis: Die Option \`${extd}-t${norm}' wurde vorher für \ + diese + Funktion benutzt, bedeutet aber jetzt, dass ein + neuer Browser-Tab erzeugt wird (siehe unten)." | $fmt echo -n " ${extd}-k${norm}, ${extd}--kill${norm} " L "Kill all Mozilla processes (first). Tries first to send" \ @@ -380,30 +382,19 @@ L "\ zu senden, um ihn höflich um seine Beendigung zu bitten. Nur wenn das nicht funktioniert, wird an den Prozess das ziemlich ruppige SIGKILL(9)-Signal gesendet ;-)" | $fmt - L "\ - Note that \`${extd}-k${norm}' (but not \ - \`${extd}--kill${norm}') may become obsolete - in future versions for POSIX conformance." \ - "\ - Hinweis: \`${extd}-k${norm}' (aber nicht \ - \`${extd}--kill${norm}') wird möglicherweise in - zukünftigen Versionen wegen angestrebter POSIX-Konformität - nicht mehr verfügbar sein." | $fmt echo -n " ${extd}-l${norm}, ${extd}--list${norm} " L "List running Mozilla processes and threads and exit." \ "Zeigt laufende Mozilla-Prozesse an." | $fold - echo -n " ${extd}-f${norm} " + echo -n " ${extd}-f${norm}, ${extd}--full${norm} " L "Force full output format. The default is to use the" \ "Erzwinge das vollständige Ausgabeformat. Standardmässig" | $fold L "\ - user-oriented format if supported. \ - ${extd}For future use.${norm}" \ + user-oriented format if supported. $future" \ "\ wird das benutzerorientierte Format benutzt, falls es - unterstützt wird. \ - ${extd}Für zukünftige Verwendung.${norm}" | $fmt + unterstützt wird. $future" | $fmt echo -n " ${extd}-n${norm}, ${extd}--new${norm} " L "Same as \`${extd}-w${norm}'. For backwards compatibility only," \ @@ -442,7 +433,7 @@ L "\ \`mailto:'-URIs erzeugen jedoch immer ein neues Fenster für die Mailbearbeitung." | $fmt - echo -n " URI " + echo -n " URI " L "The URI(s) of the resource(s) to display. If not provided" \ "URI(s) der anzuzeigenden Ressource(n). Wenn nicht" | $fold L "\ @@ -453,17 +444,18 @@ exit." \ sind, wird diese Hilfe angezeigt und das Programm beendet." | $fmt L "\ - Two or more URIs are separated by spaces, while the - second and following resources are displayed in a new + Two or more URIs are separated by spaces or comma, while + the second and following resources are displayed in a new browser window, if not specified otherwise with \ - \`${extd}-t${norm}' - or a \`mailto:' URI." \ + \`${extd}-t${norm}' or a + \`mailto:' URI." \ "\ - Zwei oder mehr URIs werden durch Leerzeichen getrennt, - dabei werden die zweite und alle weiteren Ressourcen - in einem neuen Browser-Fenster angezeigt, falls nicht - anders mit \`${extd}-t${norm}' oder durch einen \ - \`mailto:'-URI festgelegt." | $fmt + Zwei oder mehr URIs werden durch Leerzeichen oder + Komma getrennt, dabei werden die zweite und alle + weiteren Ressourcen in einem neuen Browser-Fenster + angezeigt, falls nicht anders mit \`${extd}-t${norm}' oder\ + durch + einen \`mailto:'-URI festgelegt." | $fmt echo -n " ${extd}-${norm} " L "(Re)start Mozilla with a blank page (or home page in a" \ @@ -473,16 +465,16 @@ L "\ what to do (Mozilla 1.1 and beyond). This disables any previous \`${extd}-w${norm}' or \`${extd}-t${norm}' \ options and is especially useful - in conjunction with \`${extd}--term${norm}' or \ + in conjunction with \`${extd}-T${norm}' or \ \`${extd}-k${norm}'." \ "\ der Startseite) oder Anzeige eines Fensters, welches es erlaubt, eine Aktion auszuwählen (Mozilla 1.1 und höher). Dies deaktiviert ein vorheriges \ - \`${extd}-w${norm}' oder \`${extd}-t${norm}' - und ist besonders nützlich in Verbindung mit \ - \`${extd}--term${norm}' - oder \`${extd}-k${norm}'." | $fmt + \`${extd}-w${norm}' oder + \`${extd}-t${norm}' und ist besonders nützlich in \ + Verbindung mit + \`${extd}-T${norm}' oder \`${extd}-k${norm}'." | $fmt echo -n " ${extd}-m${norm}, ${extd}--mailto${norm} " L "Pops up the mail dialog." "Zeigt den Mail-Dialog an." | $fold @@ -498,16 +490,31 @@ L "\ getrennte Adressen angegeben, so stehen diese zunächst im Feld \`An:'." | $fmt + echo -n " ${extd}-i${norm}, ${extd}--inbox${norm} " L "Opens a new Mail & Newsgroups window." \ "Öffnet ein neues Fenster für Mail & Newsgroups." | $fold echo -n " ${extd}-c${norm}, ${extd}--compose${norm} " - L "Opens a new Message Compose window. Same as \`${extd}-m${norm}' without - ADDRESS." \ + L "Opens a new Message Compose window. + Same as \`${extd}-m${norm}' without ADDRESS." \ "Öffnet ein neues Fenster zum Verfassen von Mails/News. Wie \`${extd}-m${norm}' ohne ADDRESS." | $fold - echo + + echo -n " ${extd}-C${norm}, ${extd}--command${norm} " + L "Execute arbitrary Mozilla COMMAND. $future" \ + "Beliebigen Mozilla-Befehl COMMAND ausführen. + $future" | $fold + + _XPG=1 + echo " + $(L "Note that the long options may not be available on this + system, so you must use the short options instead." \ + "Beachten Sie, dass die langen Optionen möglicherweise auf diesem System + nicht verfügbar sind. Nutzen Sie in diesem Fall die kurzen Optionen." \ + | $fmt) + " + _XPG=0 } function isMozRunning { @@ -515,24 +522,24 @@ function isMozRunning { whoami=`whoami` # BSD style user-oriented args="u " - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args args=$args" -u $whoami" # current user's processes only - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 test $? -ne 0 && args=$fallback else # SysV/Unix98 (i.e. IRIX) style fallback="-" args="-f" # full output - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args else args=$fallback fi args=$args"u $whoami" # current user's processes only - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 test $? -ne 0 && args=$fallback fi chk=`ps $args | grep mozilla-bin | grep -v grep` @@ -552,7 +559,7 @@ function KillMoz { esac Lout=`L " signal" "-Signal"` echo -n "$Lout$stat" - killall $1 mozilla-bin 2> /dev/null + killall $1 mozilla-bin 2>/dev/null result=$? # FIX ME! # allow other user's processes to run and be successful anyway @@ -560,12 +567,12 @@ function KillMoz { msg_failed else ping=1 - mozilla -remote "ping()" 2> /dev/null + mozilla -remote "ping()" 2>/dev/null error=$? test $verbose -eq 1 && echo -n $error" " >&2 while [ $error -eq 0 ] && [ $ping -le 50 ]; do let ping++ - mozilla -remote "ping()" 2> /dev/null + mozilla -remote "ping()" 2>/dev/null error=$? test $verbose -eq 1 && echo -n $error" " >&2 if [ $ping -eq 25 ]; then @@ -612,38 +619,38 @@ function ListMoz { whoami=`whoami` # BSD style user-oriented args="u $1 " - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args args=$args" -H" # with process hierarchy - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args else args=$fallback fi args=$args" -u $whoami" # current user's processes only - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 test $? -ne 0 && args=$fallback else # SysV/Unix98 (i.e. IRIX) style fallback="-" args="-f" # full output - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args else args=$fallback fi args=$args"H" # with process hierarchy - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 if [ $? -eq 0 ]; then fallback=$args else args=$fallback fi args=$args"u $whoami" # current user's processes only - ps $args 1>/dev/null 2>&1 + ps $args >/dev/null 2>&1 test $? -ne 0 && args=$fallback fi chk=`ps $args | grep mozilla-bin | grep -v grep` @@ -661,10 +668,10 @@ function ListMoz { } - test "$1" != "--version" && echo + test "$1" != "-V" -o "$1" != "--version" && echo Title - if [ -z "$1" ] || [ "$1" = "-?" ] || [ "$1" = "--help" ]; then + if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then help=1 help "$0" test -n "$1" && shift @@ -674,14 +681,15 @@ echo `L "Send suggestions and bug report "Senden Sie Vorschläge und Fehlerberichte an"`" <$mail_feedback> " | $fold - test "$1" = "--version" && exit 0 + test "$1" = "-V" -o "$1" = "--version" && exit 0 test $help -eq 1 && exit 255 # check for term/kill kill=0 - if [ "$1" = "--term" ] || [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then + if [ "$1" = "-T" ] || [ "$1" = "--term" ] || \ + [ "$1" = "-k" ] || [ "$1" = "--kill" ]; then kill=1 - if [ "$1" = "--kill" ] || [ "$1" = "-k" ]; then sig=-9; fi + if [ "$1" = "-k" ] || [ "$1" = "--kill" ]; then sig=-9; fi KillMoz if [ $? -ne 0 ] && [ $sig -eq -9 ]; then KillMoz $sig; fi shift @@ -689,13 +697,13 @@ if [ "$1" = "--term" ] || [ "$1" = "--ki fi # check for list - if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then + if [ "$1" = "-l" ] || [ "$1" = "--list" ]; then ListMoz $2 exit 0 fi # check for Mozilla - chk=`which mozilla 2> /dev/null` + chk=`which mozilla 2>/dev/null` if [ $? -ne 0 ]; then _XPG=1 echo "`basename $0`: \ @@ -755,7 +763,7 @@ while [ -n "$1" ]; do # check if the current user has Mozilla already run # AFAIK mozilla -remote "ping()" does not pay respect to different accounts _XPG=1 - chk=`ps -fu $(whoami) 2> /dev/null | grep mozilla-bin | grep -v grep` + chk=`ps -fu $(whoami) 2>/dev/null | grep mozilla-bin | grep -v grep` _XPG=0 test -z "$uri" && uri="$1" @@ -778,12 +786,12 @@ _XPG=0 error=$? if [ -n "$2" ]; then ping=1 - mozilla -remote "ping()" 2> /dev/null + mozilla -remote "ping()" 2>/dev/null error=$? test $verbose -eq 1 && echo -n $error" " >&2 while [ $error -ne 0 ] && [ $ping -le 50 ]; do let ping++ - mozilla -remote "ping()" 2> /dev/null + mozilla -remote "ping()" 2>/dev/null error=$? test $verbose -eq 1 && echo -n $error" " >&2 if [ $ping -eq 25 ]; then @@ -829,7 +837,7 @@ Bitte überprüfen Sie ihre Mozilla-Instal cmd=$cmd")" fi # checking for grep - chk=`which grep 2> /dev/null` + chk=`which grep 2>/dev/null` _XPG=1 if [ $? -ne 0 ]; then echo "`basename $0`: \`grep' "\ @@ -839,7 +847,7 @@ $(L "not found. Cannot check for \`mailt if [ -n "`echo "$uri" | grep "^mailto:"`" ]; then address="$uri" # checking for sed - chk=`which sed 2> /dev/null` + chk=`which sed 2>/dev/null` if [ $? -ne 0 ]; then echo `basename $0`": \`sed' "\ $(L "not found. Cannot handle \`mailto:' URI properly." \