: ########################################################################## # Shellscript: quote - quote text # Version : 0.2 (beta) # Author : Heiner Steven (heiner.steven@odn.de) # Date : 11/02/94 # Category : Mail, Text Utilities # SCCS-Id. : $Id: quote,v 1.1.1.1 1999/06/15 19:29:05 heiner Exp $ ########################################################################## # Description # # Notes # Needs the non-standard programs fmt and detab. ########################################################################## PN=`basename $0` # program name VER='0.2 (beta)' : ${AWK:=nawk} Usage () { echo "$PN - quote text, $VER (stv '94) usage: $PN [file ...]" >&2 exit 1 } Msg () { for i do echo "$PN: $i" >&2 done } Fatal () { Msg "$@"; exit 1; } while [ $# -gt 0 ] do case "$1" in # Your flags here --) shift; break;; -h) Usage;; -*) Usage;; *) break;; # First file name esac shift done [ -x /usr/5bin/pr ] && DETAB="/usr/5bin/pr -e -t" : ${DETAB:='tab -e'} QuoteStr=" > " # string to prepend to every line Length=64 # number of characters per line Dequote=${TMPDIR:=/tmp}/q$$ trap "rm -f $Dequote > /dev/null 2>&1" 0 trap "exit 2" 1 2 3 15 Quote () { # "Unquoted" text is in $Dequote, Quotestring is in $OldQuote OldQuote="`dequote 2> $Dequote | $DETAB 2> /dev/null`" qlen=`expr "X$OldQuote" : '.*'` # length of quote string qlen=`expr ${qlen:-1} - 1` # "X" did not belong to string [ ${qlen:=0} -gt $Length ] && qlen=0 Length=`expr $Length - $qlen` fmt -c -${Length:-64} < $Dequote | sed "s:^:$QuoteStr$OldQuote:" } if [ $# -lt 1 ] then Quote # read from stdin else for i do Quote < "$i" done fi exit 0