From 31870e774a641719623f63dffaaecad3f182163b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Fri, 13 Nov 2020 12:58:45 -0300 Subject: [PATCH] share/functions: account for the possibility of mktemp failure. --- share/functions/edit_command_buffer.fish | 1 + share/functions/funced.fish | 1 + share/functions/help.fish | 1 + share/functions/psub.fish | 4 +++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/share/functions/edit_command_buffer.fish b/share/functions/edit_command_buffer.fish index 58bf671bc..c888709ef 100644 --- a/share/functions/edit_command_buffer.fish +++ b/share/functions/edit_command_buffer.fish @@ -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 diff --git a/share/functions/funced.fish b/share/functions/funced.fish index 0b209ee0c..394a0daf6 100644 --- a/share/functions/funced.fish +++ b/share/functions/funced.fish @@ -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 diff --git a/share/functions/help.fish b/share/functions/help.fish index bc3285934..857a2f499 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -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 '' >$tmpname set page_url file://$tmpname diff --git a/share/functions/psub.fish b/share/functions/psub.fish index 74cb30b56..1357d425d 100644 --- a/share/functions/psub.fish +++ b/share/functions/psub.fish @@ -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