[TxMt] bundle temporary directory

Jay Soffian jay-txmt at soffian.org
Thu Apr 26 20:14:14 UTC 2007

On Apr 26, 2007, at 3:02 PM, Allan Odgaard wrote:

> Commands should generally use mktemp to create their temporary files.
> The added UID or user name is to prevent files from clashing with  
> other users, but that’s not a problem when using mktemp. And since  
> OS X is primarily a one-user system, keeping temporary files  
> categorized by user is IMO not a big priority (TM commands that use  
> temporary files SHOULD (though I would like to say MUST) cleanup  
> their temporary files).
> mktemp will use TMPDIR [1] (if set). So in practice we could set  
> TMPDIR in bash_init.sh (granted, this would only be for shell  
> commands).
> But the only value I see in this is, to better pinpoint bundles  
> that do not cleanup after themselves.
> [1] Unfortunately some bundles does (IIRC) need to use mktemp with  
> an absolute path, those ought to use "${TMPDIR:-/tmp}" for where to  
> place the file though (not sure if they do).

Perhaps mine is a bit of an oddball case. For my bundle command, I'm  
downloading a file from a wiki via curl, allowing it to be edited in  
TextMate, and then published back to the wiki. It's preferable to  
have the basename of the URL as the filename so that the TextMate  
window title reflects the wiki page name. So that implies a per-user  
temporary directory.

Since my bundle doesn't clean up the documents it creates (it's not  
clear when would be the appropriate time to delete the file[1]), I  
decided to use a fixed temporary directory as opposed to "mktemp -d".  
Otherwise the bundle would be polluting[2] /tmp over time with  
temporary directories (until /tmp is cleaned up at system reboot).

Anyway, I chose "/tmp/`id -u`/moinedit/<basename of URL>" which works  

So that's what precipitated the original message.


[1] doesn't make sense to delete the file when the document is  
published since there is still an open TextMate buffer backed by the  

More information about the textmate mailing list