$3 and stdout no longer refer to the same file.
This is slightly inelegant, as the old style echo foo echo blah chmod a+x $3 doesn't work anymore; the stuff you wrote to stdout didn't end up in $3. You can rewrite it as: exec >$3 echo foo echo blah chmod a+x $3 Anyway, it's better this way, because now we can tell the difference between a zero-length $3 and a nonexistent one. A .do script can thus produce either one and we'll either delete the target or move the empty $3 to replace it, whichever is right. As a bonus, this simplifies our detection of whether you did something weird with overlapping changes to stdout and $3.
This commit is contained in:
parent
c4be0050f7
commit
59201dd7a0
9 changed files with 54 additions and 29 deletions
9
t/touchtest.do
Normal file
9
t/touchtest.do
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
echo 'echo hello' >touch1.do
|
||||
redo touch1
|
||||
[ -e touch1 ] || exit 55
|
||||
rm -f touch1
|
||||
echo 'touch $3' >touch1.do
|
||||
redo touch1
|
||||
[ -e touch1 ] || exit 66
|
||||
[ -z "$(cat touch1)" ] || exit 77
|
||||
rm -f touch1.do
|
||||
Loading…
Add table
Add a link
Reference in a new issue