apenwarr-redo/t/deps/overwrite3.do
Avery Pennarun 6d767e2a65 user-friendliness sanity checks: catch common mistakes regarding $1/$2/$3.
.do files should never modify $1, and should write to *either* $3 or stdout,
but not both.  If they write to both, it's probably because they forgot to
redirect stdout to stderr, a very easy mistake to make but a hard one to
detect.

Now redo detects it for you and prints an informative message.
2010-11-22 04:43:33 -08:00

8 lines
372 B
Text

# we don't delete $3 here, we just truncate and overwrite it. But redo
# can detect this by checking the current file position of our stdout when
# we exit, and making sure it equals either 0 or the file size.
#
# If it doesn't, then we accidentally wrote to *both* stdout and a separate
# file, and we should get warned about it.
echo hello world
echo goodbye world >$3