[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

X Strike Force XFree86 SVN commit: r2025 - in trunk/debian: . local



Author: branden
Date: 2004-11-12 00:57:24 -0500 (Fri, 12 Nov 2004)
New Revision: 2025

Modified:
   trunk/debian/CHANGESETS
   trunk/debian/changelog
   trunk/debian/local/update-fonts-alias
   trunk/debian/local/update-fonts-alias.8
   trunk/debian/local/update-fonts-dir
   trunk/debian/local/update-fonts-dir.8
   trunk/debian/local/update-fonts-scale
   trunk/debian/local/update-fonts-scale.8
Log:
Perform some cleanup work on the update-fonts-{alias,dir,scale} utilities
and their manual pages.
+ Re-indent at four spaces.
+ Query terminal for its width if $COLUMNS is not set, as shell-lib.sh
  does.  Fall back to a width of 80 if stty returns garbage or nothing.
+ Rename error() to die().
+ Add usage() function and -h, --help option.
+ Use exit status 2 to indicate usage errors as opposed to operational
  failures.
+ Be more careful with quoting shell variables.
+ Add and expand comments.
+ Add SVN Id keyword.
+ Update Vim modeline.
+ Update manual pages to document changes in interface and behavior (there
  are no backwards-incomaptible changes).

Set svn:keywords property to Id on the scripts.

Set svn:executable property to "*" on the scripts.


Modified: trunk/debian/CHANGESETS
===================================================================
--- trunk/debian/CHANGESETS	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/CHANGESETS	2004-11-12 05:57:24 UTC (rev 2025)
@@ -265,4 +265,21 @@
 + Move the #DEBHELPER# expando later in the scripts where applicable.
     2019
 
+Perform some cleanup work on the update-fonts-{alias,dir,scale} utilities
+and their manual pages.
++ Re-indent at four spaces.
++ Query terminal for its width if $COLUMNS is not set, as shell-lib.sh
+  does.  Fall back to a width of 80 if stty returns garbage or nothing.
++ Rename error() to die().
++ Add usage() function and -h, --help option.
++ Use exit status 2 to indicate usage errors as opposed to operational
+  failures.
++ Be more careful with quoting shell variables.
++ Add and expand comments.
++ Add SVN Id keyword.
++ Update Vim modeline.
++ Update manual pages to document changes in interface and behavior (there
+  are no backwards-incomaptible changes).
+    2025
+
 vim:set ai et sts=4 sw=4 tw=80:

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/changelog	2004-11-12 05:57:24 UTC (rev 2025)
@@ -143,6 +143,22 @@
       post-removal scripts.
     + Move the #DEBHELPER# expando later in the scripts where applicable.
 
+  * Perform some cleanup work on the update-fonts-{alias,dir,scale} utilities
+    and their manual pages.
+    + Re-indent at four spaces.
+    + Query terminal for its width if $COLUMNS is not set, as shell-lib.sh
+      does.  Fall back to a width of 80 if stty returns garbage or nothing.
+    + Rename error() to die().
+    + Add usage() function and -h, --help option.
+    + Use exit status 2 to indicate usage errors as opposed to operational
+      failures.
+    + Be more careful with quoting shell variables.
+    + Add and expand comments.
+    + Add SVN Id keyword.
+    + Update Vim modeline.
+    + Update manual pages to document changes in interface and behavior (there
+      are no backwards-incomaptible changes).
+
   Changes by Denis Barbier and Fabio M. Di Nitto:
 
   * Edit xc/programs/xkbcomp/symbols/pc/Imakefile so that the new pc/us_intl
@@ -225,7 +241,7 @@
     exiting upon encountering the first shell interpeter that fails on the
     script; instead, attempt all the interpreters and report all that fail.
 
- -- Branden Robinson <branden@debian.org>  Wed, 10 Nov 2004 18:34:20 -0500
+ -- Branden Robinson <branden@debian.org>  Fri, 12 Nov 2004 00:50:58 -0500
 
 xfree86 (4.3.0.dfsg.1-8) unstable; urgency=high
 

Modified: trunk/debian/local/update-fonts-alias
===================================================================
--- trunk/debian/local/update-fonts-alias	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/local/update-fonts-alias	2004-11-12 05:57:24 UTC (rev 2025)
@@ -1,79 +1,126 @@
 #!/bin/sh
-# update-fonts-alias
-# compiles fonts.alias files for X font directories
-# see mkfontdir(1) for a description of the format of fonts.alias files
-# Copyright 1999,2001,2002 Branden Robinson.
+
+# $Id$
+
+# This program compiles fonts.alias files for X font directories; see
+# mkfontdir(1x) for a description of the format of fonts.alias files.
+
+# Copyright 1999, 2001, 2002, 2004 Branden Robinson.
 # Licensed under the GNU General Public License, version 2.  See the file
 # /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
 
 PROGNAME=${0##*/}
 
-# display a message, wrapping lines at the terminal width
+# Query the terminal to establish a default number of columns to use for
+# displaying messages to the user.  This is used only as a fallback in the event
+# the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while the
+# script is running, and this cannot, only being calculated once.)
+DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true
+if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then
+    DEFCOLUMNS=80
+fi
+
+# Display a message, wrapping lines at the terminal width.
 message () {
-  echo "$PROGNAME: $*" | fold -s -w ${COLUMNS:-80};
+    echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS}
 }
 
+# Display a warning message.
 warn () {
-  echo "$(message "warning: $*")" >&2;
+    message "warning: $*" >&2
 }
 
-error () {
-  echo "$(message "error: $*")" >&2
-  exit 1;
+# Display an error message and exit.
+die () {
+    message "fatal error: $*" >&2
+    exit 1
 }
 
+# Display a usage message.
+usage () {
+    if [ -n "$*" ]; then
+        message "usage error: $*"
+    fi
+    cat <<EOF
+Usage: $PROGNAME DIRECTORY ...
+       $PROGNAME { -h | --help }
+This program combines X font alias information from several packages into a
+single file that is placed in each specified X font directory DIRECTORY.  This
+utility is primarily useful to Debian package maintainer scripts.  See
+update-fonts-alias(8) for more information.
+Options:
+    -h, --help                               display this usage message and exit
+EOF
+}
+
+# Validate arguments.
+case "$1" in
+    -h|--help)
+        usage
+        exit 0
+        ;;
+    -*)
+        usage "unrecognized option" >&2
+        exit 2
+        ;;
+esac
+
 if [ $# -eq 0 ]; then
-  error "one or more font directories must be provided"
+    usage "one or more font directories must be specified" >&2
+    exit 2
 fi
 
 while [ -n "$1" ]; do
-  # try to be clever about the arguments
-  if expr "$1" : "/.*" > /dev/null 2>&1; then
-    # absolute path to X font directory was provided
-    XDIR=$1
-    ETCDIR=/etc/X11/fonts/${XDIR##*/}
-    if [ "$XDIR" = "$ETCDIR" ]; then
-      # they gave us an /etc directory as the argument
-      error "path to X font directory must be used"
+    # Try to be clever about the argument; were we given an absolute path?
+    if expr "$1" : "/.*" >/dev/null 2>&1; then
+        # Yes; an absolute path to an X font directory was provided.
+        XDIR=$1
+        ETCDIR=/etc/X11/fonts/${XDIR##*/}
+        if [ "$XDIR" = "$ETCDIR" ]; then
+            # We were given an /etc directory as an argument.
+            die "path to X font directory must be used"
+        else
+            warn "absolute path $XDIR was provided"
+        fi
     else
-      warn "absolute path $XDIR was provided"
+        # No; a relative path was provided -- assume we were given just the
+        # basename.
+        XDIR=/usr/lib/X11/fonts/$1
+        ETCDIR=/etc/X11/fonts/$1
     fi
-  else
-    # assume they just gave us the basename
-    XDIR=/usr/lib/X11/fonts/$1
-    ETCDIR=/etc/X11/fonts/$1
-  fi
-  # confirm that the directories to be operated on exist
-  for DIR in $XDIR $ETCDIR; do
-    VALID=yes
-    if [ ! -d $DIR ]; then
-      warn "$DIR does not exist or is not a directory"
-      VALID=
-    fi
-  done
-  if [ -n "$VALID" ]; then
-    # are there any files to process?
-    if [ "$(echo $ETCDIR/*.alias)" != "$ETCDIR/*.alias" ]; then
-      # write new alias file in case we are interrupted
-      cat > $XDIR/fonts.alias.update-new << EOF
+    # Confirm that the directories to be operated on exist.
+    for DIR in "$XDIR" "$ETCDIR"; do
+        VALID=yes
+        if ! [ -d "$DIR" ]; then
+            warn "$DIR does not exist or is not a directory"
+            VALID=
+        fi
+    done
+    if [ -n "$VALID" ]; then
+        # Are there any files to process?
+        if [ "$(echo "$ETCDIR"/*.alias)" != "$ETCDIR/*.alias" ]; then
+            # Write the new alias file in a temporary location in case we are
+            # interrupted.
+            cat >"$XDIR/fonts.alias.update-new" <<EOF
 !! fonts.alias -- automatically generated file.  DO NOT EDIT.
 !! To modify, see update-fonts-alias(8).
 EOF
-      for file in $ETCDIR/*.alias; do
-        echo "!! $file" >> $XDIR/fonts.alias.update-new
-        cat $file >> $XDIR/fonts.alias.update-new
-      done
-      mv $XDIR/fonts.alias.update-new $XDIR/fonts.alias
-    else
-      # no files to process, remove the one in the font dir
-      rm -f $XDIR/fonts.alias
-      # remove the font dir if it is empty
-      rmdir $XDIR > /dev/null 2>&1 || true
+            for FILE in "$ETCDIR"/*.alias; do
+                echo "!! $FILE" >>"$XDIR/fonts.alias.update-new"
+                cat "$FILE" >>"$XDIR/fonts.alias.update-new"
+            done
+            mv "$XDIR/fonts.alias.update-new" "$XDIR/fonts.alias"
+        else
+            # There are no files to process; remove any alias file already in
+            # the font directory.
+            rm -f "$XDIR/fonts.alias"
+            # Remove the font directory if it is empty.
+            rmdir "$XDIR" >/dev/null 2>&1 || true
+        fi
     fi
-  fi
-  shift
+    shift
 done
 
 exit 0
 
-# vim:ai:et:sts=2:sw=2:tw=0:
+# vim:set ai et sts=4 sw=4 tw=80:


Property changes on: trunk/debian/local/update-fonts-alias
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id

Modified: trunk/debian/local/update-fonts-alias.8
===================================================================
--- trunk/debian/local/update-fonts-alias.8	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/local/update-fonts-alias.8	2004-11-12 05:57:24 UTC (rev 2025)
@@ -24,7 +24,7 @@
 \\$2 \(laURL: \\$1 \(ra\\$3
 ..
 .if \n[.g] .mso www.tmac
-.TH update\-fonts\-alias 8 "2004\-10\-31" "Debian Project"
+.TH update\-fonts\-alias 8 "2004\-11\-11" "Debian Project"
 .SH NAME
 update\-fonts\-alias \- compile fonts.alias files
 .SH SYNOPSIS
@@ -77,15 +77,18 @@
 into
 .IR /usr/lib/X11/fonts/misc/fonts.alias .
 .PP
-The format for
+The format of
 .I fonts.alias
-files is given in the
+files is described in the
 .BR mkfontdir (1x)
 manual page.
 .PP
 An example of how to use
 .B update\-fonts\-alias
 in package maintainer scripts is provided in the Debian Policy Manual.
+.SH OPTIONS
+.B \-h\fR, \fB\-\-help
+displays a brief usage message and exits.
 .SH OPERANDS
 .B update\-fonts\-alias
 takes one or more X font directory names to operate on as operands.
@@ -99,15 +102,29 @@
 and
 .RB \(oq "update\-fonts\-alias /usr/lib/X11/fonts/75dpi" \(cq
 are not.
+.SH ENVIRONMENT
+.TP
+.B COLUMNS
+indicates the width of the terminal device in character cells.
+This value is used for formatting diagnostic messages.
+If not set, the terminal is queried using
+.BR stty (1)
+to determine its width.
+If that fails, a value of \(oq80\(cq is assumed.
 .SH DIAGNOSTICS
 .SS Errors
 .TP
-.B error: one or more font directories must be provided
+.B usage error: one or more font directories must be provided
 .B update\-fonts\-alias
 was invoked without operands.
 Supply one or more X font directory names to operate on.
 .TP
-.B error: path to X font directory must be used
+.B usage error: unrecognized option
+.B update\-fonts\-alias
+was invoked with an unrecognized option argument.
+Use only the options documented in \(lqOPTIONS\(rq, above.
+.TP
+.B fatal error: path to X font directory must be used
 A directory name was supplied that was not an X font directory name.
 Supply X font directory names only.
 .SS Warnings
@@ -132,6 +149,10 @@
 1
 .B update\-fonts\-alias
 experienced a fatal error; see the section on diagnostic messages above.
+.TP
+2
+.B update\-fonts\-alias
+was invoked with invalid arguments.
 .SH BUGS
 See
 .URL "http://bugs.debian.org/xbase\-clients"; "the Debian Bug Tracking System" .

Modified: trunk/debian/local/update-fonts-dir
===================================================================
--- trunk/debian/local/update-fonts-dir	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/local/update-fonts-dir	2004-11-12 05:57:24 UTC (rev 2025)
@@ -1,70 +1,117 @@
 #!/bin/sh
-# update-fonts-dir
-# compiles fonts.dir files for X font directories
-# see mkfontdir(1) for a description of the format of fonts.dir files
-# Copyright 1999,2001,2002 Branden Robinson.
+
+# $Id$
+
+# This program compiles fonts.dir files for X font directories; see
+# mkfontdir(1x) for a description of the format of fonts.dir files.
+
+# Copyright 1999, 2001, 2002, 2004 Branden Robinson.
 # Licensed under the GNU General Public License, version 2.  See the file
 # /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
 
 PROGNAME=${0##*/}
 ENCDIR=/usr/X11R6/lib/X11/fonts/encodings
+PATH=/usr/bin/X11:$PATH
 
-# display a message, wrapping lines at the terminal width
+# Query the terminal to establish a default number of columns to use for
+# displaying messages to the user.  This is used only as a fallback in the event
+# the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while the
+# script is running, and this cannot, only being calculated once.)
+DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true
+if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then
+    DEFCOLUMNS=80
+fi
+
+# Display a message, wrapping lines at the terminal width.
 message () {
-  echo "$PROGNAME: $*" | fold -s -w ${COLUMNS:-80};
+    echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS}
 }
 
+# Display a warning message.
 warn () {
-  echo "$(message "warning: $*")" >&2;
+    message "warning: $*" >&2
 }
 
-error () {
-  echo "$(message "error: $*")" >&2
-  exit 1;
+# Display an error message and exit.
+die () {
+    message "fatal error: $*" >&2
+    exit 1
 }
 
+# Display a usage message.
+usage () {
+    if [ -n "$*" ]; then
+        message "usage error: $*"
+    fi
+    cat <<EOF
+Usage: $PROGNAME DIRECTORY ...
+       $PROGNAME { -h | --help }
+This program is a wrapper for mkfontdir(1x) that is primarily useful to Debian
+package maintainer scripts.  See update-fonts-dir(8) for more information.
+Options:
+    -h, --help                               display this usage message and exit
+EOF
+}
+
+# Validate arguments.
+case "$1" in
+    -h|--help)
+        usage
+        exit 0
+        ;;
+    -*)
+        usage "unrecognized option" >&2
+        exit 2
+        ;;
+esac
+
 if [ $# -eq 0 ]; then
-  error "one or more font directories must be provided"
+    usage "one or more font directories must be specified" >&2
+    exit 2
 fi
 
 while [ -n "$1" ]; do
-  # try to be clever about the arguments
-  if expr "$1" : "/.*" > /dev/null 2>&1; then
-    # absolute path to X font directory was provided
-    XDIR=$1
-    ETCDIR=/etc/X11/fonts/${XDIR##*/}
-    if [ "$XDIR" = "$ETCDIR" ]; then
-      # they gave us an /etc directory as the argument
-      error "path to X font directory must be used"
+    # Try to be clever about the argument; were we given an absolute path?
+    if expr "$1" : "/.*" >/dev/null 2>&1; then
+        # Yes; an absolute path to an X font directory was provided.
+        XDIR=$1
+        ETCDIR=/etc/X11/fonts/${XDIR##*/}
+        if [ "$XDIR" = "$ETCDIR" ]; then
+            # We were given an /etc directory as an argument.
+            die "path to X font directory must be used"
+        else
+            warn "absolute path $XDIR was provided"
+        fi
     else
-      warn "absolute path $XDIR was provided"
+        # No; a relative path was provided -- assume we were given just the
+        # basename.
+        XDIR=/usr/lib/X11/fonts/$1
     fi
-  else
-    # assume they just gave us the basename
-    XDIR=/usr/lib/X11/fonts/$1
-  fi
-  # confirm that the directories to be operated on exist
-  VALID=yes
-  if [ ! -d $XDIR ]; then
-    warn "$XDIR does not exist or is not a directory"
-    VALID=
-  fi
-  if [ -n "$VALID" ]; then
-    if [ -d $ENCDIR -a -d $ENCDIR/large ]; then
-      /usr/bin/X11/mkfontdir -e $ENCDIR -e $ENCDIR/large $XDIR
-    else
-      /usr/bin/X11/mkfontdir $XDIR
+    # Confirm that the directories to be operated on exist.
+    VALID=yes
+    if ! [ -d "$XDIR" ]; then
+        warn "$XDIR does not exist or is not a directory"
+        VALID=
     fi
-    # are there any fonts in the font dir?
-    if [ "$(head -n 1 $XDIR/fonts.dir)" = "0" ]; then
-      rm -f $XDIR/fonts.dir $XDIR/encodings.dir
-      # remove the font dir if it is empty
-      rmdir $XDIR > /dev/null 2>&1 || true
+    if [ -n "$VALID" ]; then
+        # Use encoding directories if they are available.
+        if [ -d "$ENCDIR" ] && [ -d "$ENCDIR/large" ]; then
+            mkfontdir -e "$ENCDIR" -e "$ENCDIR/large" "$XDIR"
+        else
+            mkfontdir "$XDIR"
+        fi
+        # Are there any fonts in the font directory?
+        if [ "$(head -n 1 "$XDIR/fonts.dir")" = "0" ]; then
+            # There are no files to process; remove any generated files already
+            # in the font directory.
+            rm -f "$XDIR/fonts.dir" "$XDIR/encodings.dir"
+            # Remove the font dirextory if it is empty.
+            rmdir "$XDIR" >/dev/null 2>&1 || true
+        fi
     fi
-  fi
-  shift
+    shift
 done
 
 exit 0
 
-# vim:ai:et:sts=2:sw=2:tw=0:
+# vim:set ai et sts=4 sw=4 tw=80:


Property changes on: trunk/debian/local/update-fonts-dir
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Id

Modified: trunk/debian/local/update-fonts-dir.8
===================================================================
--- trunk/debian/local/update-fonts-dir.8	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/local/update-fonts-dir.8	2004-11-12 05:57:24 UTC (rev 2025)
@@ -24,7 +24,7 @@
 \\$2 \(laURL: \\$1 \(ra\\$3
 ..
 .if \n[.g] .mso www.tmac
-.TH update\-fonts\-dir 8 "2004\-10\-31" "Debian Project"
+.TH update\-fonts\-dir 8 "2004\-11\-11" "Debian Project"
 .SH NAME
 update\-fonts\-dir \- compile fonts.dir files
 .SH SYNOPSIS
@@ -73,15 +73,18 @@
 file in that directory contains information about the font files provided
 by both packages.
 .PP
-The format for
+The format of
 .I fonts.dir
-files is given in the
+files is described in the
 .BR mkfontdir (1x)
 manual page.
 .PP
 An example of how to use
 .B update\-fonts\-dir
 in package maintainer scripts is provided in the Debian Policy Manual.
+.SH OPTIONS
+.B \-h\fR, \fB\-\-help
+displays a brief usage message and exits.
 .SH OPERANDS
 .B update\-fonts\-dir
 takes one or more X font directory names to operate on as operands.
@@ -95,15 +98,29 @@
 and
 .RB \(oq "update\-fonts\-dir /usr/lib/X11/fonts/75dpi" \(cq
 are not.
+.SH ENVIRONMENT
+.TP
+.B COLUMNS
+indicates the width of the terminal device in character cells.
+This value is used for formatting diagnostic messages.
+If not set, the terminal is queried using
+.BR stty (1)
+to determine its width.
+If that fails, a value of \(oq80\(cq is assumed.
 .SH DIAGNOSTICS
 .SS Errors
 .TP
-.B error: one or more font directories must be provided
+.B usage error: one or more font directories must be provided
 .B update\-fonts\-dir
 was invoked without operands.
 Supply one or more X font directory names to operate on.
 .TP
-.B error: path to X font directory must be used
+.B usage error: unrecognized option
+.B update\-fonts\-dir
+was invoked with an unrecognized option argument.
+Use only the options documented in \(lqOPTIONS\(rq, above.
+.TP
+.B fatal error: path to X font directory must be used
 A directory name was supplied that was not an X font directory name.
 Supply X font directory names only.
 .SS Warnings
@@ -128,6 +145,10 @@
 1
 .B update\-fonts\-dir
 experienced a fatal error; see the section on diagnostic messages above.
+.TP
+2
+.B update\-fonts\-dir
+was invoked with invalid arguments.
 .SH BUGS
 See
 .URL "http://bugs.debian.org/xbase\-clients"; "the Debian Bug Tracking System" .

Modified: trunk/debian/local/update-fonts-scale
===================================================================
--- trunk/debian/local/update-fonts-scale	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/local/update-fonts-scale	2004-11-12 05:57:24 UTC (rev 2025)
@@ -1,114 +1,151 @@
 #!/bin/sh
-#
-# This program generates fonts.scale files for X font directories.  See
+
+# $Id$
+
+# This program generates fonts.scale files for X font directories; see
 # mkfontdir(1x) for a description of the format of fonts.scale files.
-#
+
 # Copyright 1999--2002, 2004 Branden Robinson.
 # Licensed under the GNU General Public License, version 2.  See the file
 # /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
 
-# $Id$
-
 PROGNAME=${0##*/}
 
 # Query the terminal to establish a default number of columns to use for
-# displaying messages to the user.  This is used only as a fallback in the
-# event the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while
-# the script is running, and this cannot, only being calculated once.)
+# displaying messages to the user.  This is used only as a fallback in the event
+# the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while the
+# script is running, and this cannot, only being calculated once.)
 DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true
 if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then
-  DEFCOLUMNS=80
+    DEFCOLUMNS=80
 fi
 
+# Display a message, wrapping lines at the terminal width.
 message () {
-  # pretty-print messages of arbitrary length
-  echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2
+    echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS}
 }
 
-observe () {
-  if [ -n "$DEBUG" ]; then
-    message "note: $*"
-  fi
+# Display a debugging message.
+trace () {
+    if [ -n "$DEBUG" ]; then
+        message "note: $*" >&2
+    fi
 }
 
+# Display a warning message.
 warn () {
-  message "warning: $*"
+    message "warning: $*" >&2
 }
 
+# Display an error message and exit.
 die () {
-  message "error: $*"
-  exit 1
+    message "fatal error: $*" >&2
+    exit 1
 }
 
+# Display a usage message.
+usage () {
+    if [ -n "$*" ]; then
+        message "usage error: $*"
+    fi
+    cat <<EOF
+Usage: $PROGNAME DIRECTORY ...
+       $PROGNAME { -h | --help }
+This program combines scalable X font information from several packages into a
+single file that is placed in each specified X font directory DIRECTORY.  This
+utility is primarily useful to Debian package maintainer scripts.  See
+update-fonts-scale(8) for more information.
+Options:
+    -h, --help                               display this usage message and exit
+EOF
+}
+
+# Validate arguments.
+case "$1" in
+    -h|--help)
+        usage
+        exit 0
+        ;;
+    -*)
+        usage "unrecognized option" >&2
+        exit 2
+        ;;
+esac
+
 if [ $# -eq 0 ]; then
-  die "one or more font directories must be provided"
+    usage "one or more font directories must be specified" >&2
+    exit 2
 fi
 
 while [ -n "$1" ]; do
-  # try to be clever about the arguments
-  if expr "$1" : "/.*" >/dev/null 2>&1; then
-    # absolute path to X font directory was provided
-    XDIR=$1
-    ETCDIR=/etc/X11/fonts/${XDIR##*/}
-    if [ "$XDIR" = "$ETCDIR" ]; then
-      # they gave us an /etc directory as the argument
-      die "path to X font directory must be used"
+    # Try to be clever about the argument; were we given an absolute path?
+    if expr "$1" : "/.*" >/dev/null 2>&1; then
+        # Yes; an absolute path to an X font directory was provided.
+        XDIR=$1
+        ETCDIR=/etc/X11/fonts/${XDIR##*/}
+        if [ "$XDIR" = "$ETCDIR" ]; then
+            # We were given an /etc directory as an argument.
+            die "path to X font directory must be used"
+        else
+            warn "absolute path $XDIR was provided"
+        fi
     else
-      warn "absolute path $XDIR was provided"
+        # No; a relative path was provided -- assume we were given just the
+        # basename.
+        XDIR=/usr/lib/X11/fonts/$1
+        ETCDIR=/etc/X11/fonts/$1
     fi
-  else
-    # assume they just gave us the basename
-    XDIR="/usr/lib/X11/fonts/$1"
-    ETCDIR="/etc/X11/fonts/$1"
-  fi
-  # confirm that the directories to be operated on exist
-  for DIR in "$XDIR" "$ETCDIR"; do
-    VALID=yes
-    if [ ! -d "$DIR" ]; then
-      warn "$DIR does not exist or is not a directory"
-      VALID=
+    # Confirm that the directories to be operated on exist.
+    for DIR in "$XDIR" "$ETCDIR"; do
+        VALID=yes
+        if ! [ -d "$DIR" ]; then
+            warn "$DIR does not exist or is not a directory"
+            VALID=
+        fi
+    done
+    if [ -n "$VALID" ]; then
+        # Are there any files to process?
+        if [ "$(echo "$ETCDIR"/*.scale)" != "$ETCDIR/*.scale" ]; then
+            for SCALEFILE in "$ETCDIR"/*.scale; do
+                # Only write fonts to the .scale file that actually exist, so
+                # that removed-but-not-purged scalable font packages do not
+                # register nonexistent fonts; this has the desirable side effect
+                # that the count at the top of the file is also omitted.
+                #
+                # XXX: This technique will be tricked into yielding false
+                # negatives if the font filename has whitespace in it.
+                while read FONTFILE FONTNAME; do
+                    if [ -f "$XDIR/$FONTFILE" ]; then
+                        echo "$FONTFILE $FONTNAME" \
+                          >>"$XDIR/fonts.scale.update-tmp"
+                    else
+                        trace "$SCALEFILE references nonexistent font file" \
+                          "$FONTFILE; skipping"
+                    fi
+                done <"$SCALEFILE"
+            done
+            if [ -e "$XDIR/fonts.scale.update-tmp" ]; then
+                # Write the new scale file to a temporary location in case we
+                # are interrupted.  Write the new count to the top of file.  Use
+                # cat and pipe to wc so wc doesn't report the filename.
+                cat "$XDIR/fonts.scale.update-tmp" | wc -l | tr -d '[:blank:]' \
+                  >"$XDIR/fonts.scale.update-new"
+                cat "$XDIR/fonts.scale.update-tmp" \
+                  >>"$XDIR/fonts.scale.update-new"
+                mv "$XDIR/fonts.scale.update-new" "$XDIR/fonts.scale"
+                rm "$XDIR/fonts.scale.update-tmp"
+            fi
+        else
+            # No files to process; remove any fonts.scale file already in the
+            # font directory.
+            rm -f "$XDIR/fonts.scale"
+            # Remove the font directory if it is empty.
+            rmdir "$XDIR" >/dev/null 2>&1 || true
+        fi
     fi
-  done
-  if [ -n "$VALID" ]; then
-    # are there any files to process?
-    if [ "$(echo $ETCDIR/*.scale)" != "$ETCDIR/*.scale" ]; then
-      for SCALEFILE in "$ETCDIR"/*.scale; do
-        # Only write fonts to the .scale file that actually exist, so that
-        # removed-but-not-purged scalable font packages do not register
-        # nonexistent fonts; this has the desirable side effect that the count
-        # at the top of the file is also omitted.
-        #
-        # XXX: This technique will be tricked into yielding false negatives if
-        # the font filename has whitespace in it.
-        while read FONTFILE FONTNAME; do
-          if [ -f "$XDIR/$FONTFILE" ]; then
-            echo "$FONTFILE $FONTNAME" >>"$XDIR/fonts.scale.update-tmp"
-          else
-            observe "$SCALEFILE references nonexistent font file $FONTFILE;" \
-              "skipping"
-          fi
-        done < $SCALEFILE
-      done
-      if [ -e "$XDIR/fonts.scale.update-tmp" ]; then
-        # Write new scale file to .update-new in case we are interrupted.
-        # Write the new count to the top of file.  Use cat and pipe to wc so wc
-        # doesn't report the filename.
-        cat "$XDIR/fonts.scale.update-tmp" | wc -l | tr -d '[:blank:]' \
-          >"$XDIR/fonts.scale.update-new"
-        cat "$XDIR/fonts.scale.update-tmp" >>"$XDIR/fonts.scale.update-new"
-        mv "$XDIR/fonts.scale.update-new" "$XDIR/fonts.scale"
-        rm "$XDIR/fonts.scale.update-tmp"
-      fi
-    else
-      # no files to process, remove the one in the font dir
-      rm -f "$XDIR/fonts.scale"
-      # remove the font dir if it is empty
-      rmdir "$XDIR" >/dev/null 2>&1 || true
-    fi
-  fi
-  shift
+    shift
 done
 
 exit 0
 
-# vim:set ai et sts=2 sw=2 tw=80:
+# vim:set ai et sts=4 sw=4 tw=80:


Property changes on: trunk/debian/local/update-fonts-scale
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/debian/local/update-fonts-scale.8
===================================================================
--- trunk/debian/local/update-fonts-scale.8	2004-11-12 02:52:26 UTC (rev 2024)
+++ trunk/debian/local/update-fonts-scale.8	2004-11-12 05:57:24 UTC (rev 2025)
@@ -24,7 +24,7 @@
 \\$2 \(laURL: \\$1 \(ra\\$3
 ..
 .if \n[.g] .mso www.tmac
-.TH update\-fonts\-scale 8 "2004\-04\-11" "Debian Project"
+.TH update\-fonts\-scale 8 "2004\-11\-12" "Debian Project"
 .SH NAME
 update\-fonts\-scale \- generate fonts.scale files
 .SH SYNOPSIS
@@ -90,6 +90,9 @@
 An example of how to use
 .B update\-fonts\-scale
 in package maintainer scripts is provided in the Debian Policy Manual.
+.SH OPTIONS
+.B \-h\fR, \fB\-\-help
+displays a brief usage message and exits.
 .SH OPERANDS
 .B update\-fonts\-scale
 takes one or more X font directory names to operate on as operands.
@@ -106,31 +109,32 @@
 .SH ENVIRONMENT
 .TP
 .B COLUMNS
-This variable is used to format diagnostic messages so that they fit the
-width of the terminal.
-If not set, a terminal width of 80 columns is assumed.
+indicates the width of the terminal device in character cells.
+This value is used for formatting diagnostic messages.
+If not set, the terminal is queried using
+.BR stty (1)
+to determine its width.
+If that fails, a value of \(oq80\(cq is assumed.
 .TP
 .B DEBUG
-This variable determines whether low\-level diagnostic messages are issued
-to standard error output.
+determines whether low\-level diagnostic messages are issued to standard error
+output.
 A null (empty) or unset value indicates that they are not, and a non\-null
 value indicates that they are.
 .SH DIAGNOSTICS
-.B update\-fonts\-scale
-reports three types of diagnostics; errors, which are fatal and cause the
-command to abort processing; warnings, which are errors that the program
-attempts to recover from; and notes, which are only visible if the
-environment variable
-.B DEBUG
-is set to a non\-null value.
 .SS Errors
 .TP
-.B error: one or more font directories must be provided
+.B usage error: one or more font directories must be provided
 .B update\-fonts\-scale
 was invoked without operands.
 Supply one or more X font directory names to operate on.
 .TP
-.B error: path to X font directory must be used
+.B usage error: unrecognized option
+.B update\-fonts\-scale
+was invoked with an unrecognized option argument.
+Use only the options documented in \(lqOPTIONS\(rq, above.
+.TP
+.B fatal error: path to X font directory must be used
 A directory name was supplied that was not an X font directory name.
 Supply X font directory names only.
 .SS Warnings
@@ -147,6 +151,8 @@
 .B update\-fonts\-scale
 skipped it.
 .SS Notes
+Notes are only displayed under special circumstances; see \(lqENVIRONMENT\(rq.
+above.
 .TP
 .BI "note: " index " references nonexistent font file " filename
 The index file
@@ -167,6 +173,10 @@
 1
 .B update\-fonts\-scale
 experienced a fatal error; see the section on diagnostic messages above.
+.TP
+2
+.B update\-fonts\-scale
+was invoked with invalid arguments.
 .SH BUGS
 See
 .URL "http://bugs.debian.org/xbase\-clients"; "the Debian Bug Tracking System" .



Reply to: