You can't have a "self-contained test" if you are testing writing to a file. You need to write to the file. The shell commands showed the output of cat. The test showed exactly what the output indicated:
If you pass append() an empty string, as shown in the spew() example I was replying to, you will get an error.
And the reason to do this in the OP's case is not for file permission preservation, but for file locking.
In reply to Re^7: Clear the contents of the text file
by 1nickt
in thread Clear the contents of the text file
by shroh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |