#! /bin/sh # -*-sh-*- # # $Id: txtlib.in,v 1.5 2004/04/08 01:36:24 mdw Exp $ # # Manipulate simple libraries of text chunks # # (c) 1997 Mark Wooding # #----- Licensing notice ----------------------------------------------------- # # This file is part of the Common Files Distribution (`common'). # # `Common' is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # `Common' is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with `common'; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. set -e # --- Handle command line arguments --- files="" mode=x out="" # --- Parse command line arguments --- while [ $# -gt 0 ]; do case $1 in -h | --h | --he | --hel | --help) cat <&2 exit 1 ;; *) break ;; esac shift done test "$out" = "-" && out="" # --- Build a `sed' script --- case $mode in l) sed -n -e "/^.*\*@-\([-a-zA-Z0-9_]*\)-@\*.*$/ s//\1/p" /dev/null "$@" ;; x) t=${TMPDIR-/tmp}/txtlib.$$ if mkdir -m 700 $t; then : else echo >&2 "txtlib: could not create temporary directory" exit 1 fi sedfile=/$t/sed while read LINE; do echo "/\*@-$LINE-@\*/,/\*@-#-@\*/ p" done >$sedfile test -z "$out" || exec >"$out" sed -e '/\*@-[-a-zA-Z0-9_]*-@\*/ i\ *@-#-@*' /dev/null "$@" | sed -n -f $sedfile | sed -e '/\*@-#-@\*/ d' rm -rf $t ;; esac