On 06/02/2010 04:08 AM, Sebastien Andre wrote: > Hello guys! > > When needing a temporary named pipe in shell scripts, I've often been > writing the following function: > > mktempfifo() { > local path=$(mktemp -t) > rm "$path" > mkfifo -m 0600 "$path" > echo "$path" > } First off, thanks for the suggestion. What's wrong with the example given in the manual (info coreutils mktemp), as adjusted to your usage pattern: mktempfifo() { local dir dir=$(mktemp -t -d) || return 1 mkfifo -m 0600 "$dir/fifo" || return 1 echo "$dir/fifo" } other than the fact that you have to remember to also remove the temporary directory? And if you need to create more than one secure temporary object, it becomes a much easier paradigm to create a single secure directory in which to place all the other objects, and use a simple 'rm -rf "$tmpdir"' in your cleanup paths. That's how coreutils 'make check' works - every test is run inside its own temporary directory, and within the body of the test, there is no need to worry about name collisions from external processes. > > I was wondering if anybody would be interested in having an option -p --pipe > (or -f --fifo since -p is deprecated) > to create temporary named pipes? You are correct that a short option -p cannot be used. And I'm reluctant to burn -f unless there is another implementation that already does it. But you have a point that adding a long option --fifo may make sense. However, I thought about that same point the last time I touched mktemp(1), and did not implement it at that time because I felt that a temporary directory was enough. But I can be swayed if you can present good arguments why the addition is better than using existing tools. > > PS: I can try to provide a patch if my bug is accepted Patches speak volumes, although by the time you add the code and the documentation, your contribution would probably be non-trivial and require copyright assignment to the FSF. Let us know if you'd like to start that process. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org