Closed rsyring closed 5 years ago
We already have --remove
to make temporary virtualenvs.
So what you're asking for is to generate a random name.
I don't like it. I think the user should be involved in documenting their intention at least enough to give it a name. Then if they didn't use --remove
or it failed somehow, at least it has a name they provided. The idea that people are running vex with -t
and then ending up with a lot of machine-created virtualenvs in ~/.virtualenvs
isn't something I like very much because I expect that directory at least to have virtualenvs which are relevant to humans so it is possible to list the actual human-made ones.
I would recommend if you're creating temporary virtualenvs in random locations that they actually go in /tmp
or a similar place that will be cleaned up when the execution is finished, not put into a user-facing namespace.
Another issue is that I don't want to keep increasing the surface area of the vex interface without necessity. As you show, this is something that can easily enough be done around vex for the specific applications where it's necessary.
A better solution for the random name (and path) is to use the standard mktemp -d
command:
tmpdir=$(mktemp -d)
vex --path "$tmpdir" ...
rm -rf "$tmpdir" # even better if put in a trap EXIT so it's guaranteed to remove afterwards
mktemp
is the standard GNU/Linux tool for creating temporary, random directories in a secure way.
I'd like to see a
-t
option that would essentially do this:vex -mr tmp-$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 4 | head -n 1)
Example usage: