Path: utzoo!utgpu!water!watmath!watdragon!twhlai From: twhlai@watdragon.waterloo.edu (Tony Lai) Newsgroups: alt.sources Subject: hold -- a program to buffer input Message-ID: <8082@watdragon.waterloo.edu> Date: 31 Jul 88 03:14:57 GMT Reply-To: twhlai@watdragon.waterloo.edu (Tony Lai) Distribution: alt Organization: U. of Waterloo, Ontario Lines: 40 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