5 # $Id: txtlib.in,v 1.2 1999/11/11 17:49:15 mdw Exp $
7 # Manipulate simple libraries of text chunks
9 # (c) 1997 Mark Wooding
12 #----- Licensing notice -----------------------------------------------------
14 # This file is part of the Common Files Distribution (`common').
16 # `Common' is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # `Common' is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with `common'; if not, write to the Free Software Foundation,
28 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #----- Revision history -----------------------------------------------------
33 # Revision 1.2 1999/11/11 17:49:15 mdw
34 # Regular expression fixes for parsing version numbers.
36 # Revision 1.1.1.1 1999/05/05 19:23:47 mdw
37 # New import. The old CVS repository was lost in a disk disaster.
40 # --- Handle command line arguments ---
46 # --- Parse command line arguments ---
48 while [ $# -gt 0 ]; do
50 -h | --h | --he | --hel | --help)
52 Usage: txtlib [-lx] [-o FILE] [LIBRARY...]
54 In \`extract' mode (-x, default), extracts chunks named on standard input
55 from the list of libraries, and writes the result to standard output.
57 In \`list' mode (-l), lists the chunks defined in the text libraries given.
61 -h, --help Print this help text.
62 -v, --version Print the program's version number.
63 -l, --list List chunks defined in text libraries.
64 -x, --extract Extract chunks from text libraries (default).
65 -o, --output=FILE Extract chunks to FILE, not standard output.
69 -v | --v | --ve | --ver | --vers | --versi | --versio | --version)
70 version=`echo '$Revision: 1.2 $' |
71 sed -n -e 's;^.*: \([0-9.]*\) *\\$;\1;p'`
72 echo "txtlib $version; Common Files Distribution version @VERSION@"
75 -o | --o | --ou | --out | --outp | --outpu | --output)
80 out=`echo $1 | sed -e 's/^-[a-z]//'`
82 --o=* | --ou=* | --out=* | --outp=* | --outpu=* | --output=*)
83 out=`echo $1 | sed -e 's/^--[a-z]*=//'`
85 -l | --l | --li | --lis | --list)
88 -x | --e | --ex | --ext | --extr | --extra | --extrac | --extract)
99 echo "txtlib: unknown option \`$1'" >&2
109 test "$out" = "-" && out=""
111 # --- Build a `sed' script ---
115 sed -n -e "/^.*\*@-\([-a-zA-Z0-9_]*\)-@\*.*$/ s//\1/p" "$@"
119 if mkdir -m 700 $t; then :
121 echo >&2 "txtlib: could not create temporary directory"
126 echo "/\*@-$LINE-@\*/,/\*@-#-@\*/ p"
128 test -z "$out" || exec >$out
129 sed -e '/\*@-[-a-zA-Z0-9_]*-@\*/ i\
130 *@-#-@*' "$@" | sed -n -f $sedfile | sed -e '/\*@-#-@\*/ d'