share/functions: account for the possibility of mktemp failure.

This commit is contained in:
Érico Rolim 2020-11-13 12:58:45 -03:00 committed by Fabian Homborg
parent ef4f3b7334
commit 31870e774a
4 changed files with 6 additions and 1 deletions

View file

@ -1,5 +1,6 @@
function edit_command_buffer --description 'Edit the command buffer in an external editor'
set -l f (mktemp)
or return 1
if set -q f[1]
mv $f $f.fish
set f $f.fish

View file

@ -80,6 +80,7 @@ function funced --description 'Edit function definition'
set -q TMPDIR
or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
or return 1
set -l tmpname $tmpdir/$funcname.fish
if functions -q -- $funcname

View file

@ -169,6 +169,7 @@ function help --description 'Show help for the fish shell'
set -q TMPDIR
or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/help.XXXXXX)
or return 1
set -l tmpname $tmpdir/help.html
echo '<meta http-equiv="refresh" content="0;URL=\''$clean_url'\'" />' >$tmpname
set page_url file://$tmpname

View file

@ -26,7 +26,7 @@ function psub --description "Read from stdin into a file and output the filename
# that the command substitution exits without needing to wait for
# all the commands to exit.
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
or return
or return 1
set filename $dirname/psub.fifo"$_flag_suffix"
command mkfifo $filename
# Note that if we were to do the obvious `cat >$filename &`, we would deadlock
@ -35,9 +35,11 @@ function psub --description "Read from stdin into a file and output the filename
command tee $filename >/dev/null &
else if test -z "$_flag_suffix"
set filename (mktemp $tmpdir/.psub.XXXXXXXXXX)
or return 1
command cat >$filename
else
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
or return 1
set filename "$dirname/psub$_flag_suffix"
command cat >$filename
end