mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
harden psub
again an undef TMPDIR
This commit is contained in:
parent
bdee54bd10
commit
4853ec0281
1 changed files with 6 additions and 7 deletions
|
@ -51,25 +51,24 @@ function psub --description "Read from stdin into a file and output the filename
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l TMPDIR $TMPDIR
|
set -l tmpdir /tmp
|
||||||
if test -z "$TMPDIR[1]"
|
set -q TMPDIR
|
||||||
set TMPDIR /tmp
|
and set tmpdir $TMPDIR
|
||||||
end
|
|
||||||
|
|
||||||
if test use_fifo = 1
|
if test use_fifo = 1
|
||||||
# Write output to pipe. This needs to be done in the background so
|
# Write output to pipe. This needs to be done in the background so
|
||||||
# that the command substitution exits without needing to wait for
|
# that the command substitution exits without needing to wait for
|
||||||
# all the commands to exit
|
# all the commands to exit
|
||||||
set dirname (mktemp -d "$TMPDIR[1]"/.psub.XXXXXXXXXX)
|
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
||||||
or return
|
or return
|
||||||
set filename $dirname/psub.fifo"$suffix"
|
set filename $dirname/psub.fifo"$suffix"
|
||||||
mkfifo $filename
|
mkfifo $filename
|
||||||
cat >$filename &
|
cat >$filename &
|
||||||
else if test -z $suffix
|
else if test -z $suffix
|
||||||
set filename (mktemp "$TMPDIR[1]"/.psub.XXXXXXXXXX)
|
set filename (mktemp $tmpdir/.psub.XXXXXXXXXX)
|
||||||
cat >$filename
|
cat >$filename
|
||||||
else
|
else
|
||||||
set dirname (mktemp -d "$TMPDIR[1]"/.psub.XXXXXXXXXX)
|
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
||||||
set filename $dirname/psub"$suffix"
|
set filename $dirname/psub"$suffix"
|
||||||
cat >$filename
|
cat >$filename
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue