hold -- a program to buffer input

rasasoft at funman.UUCP rasasoft at funman.UUCP
Tue Sep 20 15:34:00 AEST 1988


> twhlai at watdragon.UUCP writes ( 5:14 am  Jul 31, 1988 in funman:ALT.SOURCES): 
> Subject: hold -- a program to buffer input
> A few weeks ago, a program called "hold" was posted to comp.sources.misc that
> buffers its input.  The idea is that something like
>   sed 's/a/b/g' foo > foo
> makes foo a null file, while
>   sed 's/a/b/g' foo | hold foo
> changes all a's to b's in foo, because hold prevents foo from being overwritten
> before sed finishes reading foo.
> 
> Here is a simple Bourne shell script to do this.
> 
> #!/bin/sh
> #
> # This is a shell archive.  Remove anything before this line,
> # then unpack it by saving it in a file and typing "sh file".
> #
> # The files contained herein are:
> #  hold
> #
> echo 'extracting hold'
> if test -f hold; then echo 'shar: not overwriting hold'; else
> sed 's/^X//' << 'EOF' > hold
> X#!/bin/sh
> Xif [ $# -gt 1 ]
> Xthen
> X  echo 'Usage: hold [file]' 1>&2
> X  exit 1
> Xfi
> Xf=/tmp/hold.$$
> Xcat > $f
> Xcase $# in
> X0) cat $f ;;
> X1) cat $f > $1
> Xesac
> X/bin/rm -f $f
> EOF
> if test `wc -c < hold` -ne 158; then
> echo 'shar: hold was damaged during transit (should have been 158 bytes)'
> fi
> fi
> exit 0



More information about the Alt.sources mailing list