aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/psub.fish
diff options
context:
space:
mode:
Diffstat (limited to 'share/functions/psub.fish')
-rw-r--r--share/functions/psub.fish11
1 files changed, 3 insertions, 8 deletions
diff --git a/share/functions/psub.fish b/share/functions/psub.fish
index 42e34c73..7877aa4e 100644
--- a/share/functions/psub.fish
+++ b/share/functions/psub.fish
@@ -45,21 +45,16 @@ function psub --description "Read from stdin into a file and output the filename
return
end
- # Find unique file name for writing output to
- while true
- set filename /tmp/.psub.(echo %self).(random);
- if not test -e $filename
- break;
- end
- end
-
if test use_fifo = 1
# Write output to pipe. This needs to be done in the background so
# that the command substitution exits without needing to wait for
# all the commands to exit
+ set dir (mktemp -d /tmp/.psub.XXXXXXXXXX); or return
+ set filename $dir/psub.fifo
mkfifo $filename
cat >$filename &
else
+ set filename (mktemp /tmp/.psub.XXXXXXXXXX)
cat >$filename
end