On Thu, 15 Aug 2019, Sven Schreiber wrote:
Am 14.08.2019 um 23:48 schrieb Allin Cottrell:
> I've noticed that some function packages make use of "home-made"
> functions to create a temporary file in the user's dotdir. These
> probably work fine in most cases, but they're not safe against race
> conditions and I thought we should have a "proper" way of doing the job.
>
> That's now provided by outfile. You say
>
> outfile foo --tempfile
>
> where "foo" is either the name of an existing string variable or a valid
> hansl identifier that's not yet used for any object.
Thanks Allin. The problem I see is that 'outfile' typically accepts also
literal (even [only?] unquoted) filename strings, as in the
documentation example:
outfile outer.txt
Your description of the --tempfile option sounds as if only string
variables are possible there.
Actually the automatic creation of a non-declared string object is also
a bit unusual for hansl, no? For example bwrite or mwrite don't seem to
do that. Not sure yet about the best syntactic solution.
I take your point, but in this respect the --tempfile option to
outfile works in exactly the same way as the relatively long-standing
--buffer option (which is why I did it that way). In both cases the
"filename" argument is reinterpreted as a name-of-string argument, and
the string object is created if it doesn't already exist.
The argument to outfile without the --buffer or --tempfile options is
always taken to be a filename; with one of those options it is always
taken to be the name of a string. I've tried to make this clearer in
the current help for "outfile".
I thought of doing --tempfile on the pattern:
outfile --tempname=foo
with no actual argument, and the required parameter for --tempfile
naming an existing string variable that would get the name of the
file. But then I realized that this would be quite different from the
otherwise similar --buffer option.
An alternative, and maybe cleaner, way would be to rejig both --buffer
and --tempfile on the latter pattern, and deprecate the old usage for
buffer.
Allin