I discovered that, given a script as such:
#!/bin/bash
echo truncate >&1
If it is invoked like so:
echo data>test; ./iobug.sh >>test; cat test
It will truncate the test file, rather than append to it. This is not
behavior I would expect. I'm aware that it's a bit silly to redirect stdout
to stdout, but I recently ran across a script where someone did something
similar, which brought this to my attention.
#!/bin/bash
echo truncate >&2
and echo data>test; ./iobug.sh 2>>test; cat test
works as expected. Can someone explain this?