diff --git a/share/functions/psub.fish b/share/functions/psub.fish index b764d6f35..8c8a7eac8 100644 --- a/share/functions/psub.fish +++ b/share/functions/psub.fish @@ -29,7 +29,10 @@ function psub --description "Read from stdin into a file and output the filename or return set filename $dirname/psub.fifo"$_flag_suffix" mkfifo $filename - cat >$filename & + # Note that if we were to do the obvious `cat >$filename &`, we would deadlock + # because $filename may be opened before the fork. Use tee to ensure it is opened + # after the fork. + tee $filename >/dev/null & else if test -z "$_flag_suffix" set filename (mktemp $tmpdir/.psub.XXXXXXXXXX) cat >$filename