From 4853ec028180664e449cf9a8c598befdd1923a84 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Tue, 4 Jul 2017 16:35:32 -0700 Subject: [PATCH] harden `psub` again an undef TMPDIR --- share/functions/psub.fish | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/share/functions/psub.fish b/share/functions/psub.fish index afed1788e..37d702ca0 100644 --- a/share/functions/psub.fish +++ b/share/functions/psub.fish @@ -51,25 +51,24 @@ function psub --description "Read from stdin into a file and output the filename return 1 end - set -l TMPDIR $TMPDIR - if test -z "$TMPDIR[1]" - set TMPDIR /tmp - end + set -l tmpdir /tmp + set -q TMPDIR + and set tmpdir $TMPDIR 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 dirname (mktemp -d "$TMPDIR[1]"/.psub.XXXXXXXXXX) + set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX) or return set filename $dirname/psub.fifo"$suffix" mkfifo $filename cat >$filename & else if test -z $suffix - set filename (mktemp "$TMPDIR[1]"/.psub.XXXXXXXXXX) + set filename (mktemp $tmpdir/.psub.XXXXXXXXXX) cat >$filename else - set dirname (mktemp -d "$TMPDIR[1]"/.psub.XXXXXXXXXX) + set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX) set filename $dirname/psub"$suffix" cat >$filename end