Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [RFC] adding zmktemp command

On 3/28/2019 10:17 AM, Peter Stephenson wrote:
On Wed, 2019-03-27 at 16:16 -0500, Clinton Bunch wrote:
But it also seems like it would be a good fit into the zsh/files module
(mktemp and zf_mktemp instead of zmktemp)

It occurs to me that one reason for doing this might be that you could
add a zf_mkstemp function (no reason for compatibility with any external
command) that both creates and opens a file using mkstemp(), returning
the file descriptor in REPLY as usual.  This is then secure.
That's something that's hard to do without a builtin.


I was actually planning on adding a -f option to return a fd  as the zsystem flock command does.  This could then be used in print -u, sysseek, and read -u statements.  I would also probably use mkstemps (hand-rolled where not available in libc) as suffixes can be a good thing.  This would also relieve the predictability issue with HP-UX's mkstemp.

I didn't think about using REPLY by default.  That could cause issues with use of read -u if they rewind the file

Messages sorted by: Reverse Date, Date, Thread, Author