In shell scripts, one can oftentimes save a few bytes by creating temporary files instead of storing information in variables. Given that the lion share of the work is usually done by invoking external programs, this is not only the golfiest, but the most natural choice.
For example, instead of the Bash script
t=`command1`
echo -n "$t"|command2
echo -n "$t"|command3
one could use
command1>t
command2<t
command3<t
which is guaranteed to work as intended and a whopping 24 bytes shorter.
Now, a production-level Bash script would create a temporary file or directory with mktemp
and clean up after itself before exiting, but what should a code golf answer do?
Where should programs be allowed to create temporary files?
In particular, is it OK to simply create a file in the current directory, possibly overwriting other files in the process?1
Do programs have to delete the files they created in the current directory (if allowed)?
Do programs have to delete the files they created in
/tmp
(which the system should eventually delete on its own)?
1 It goes without saying that the answer should include a heads-up in this case.