mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 10:57:30 +08:00
share/functions: account for the possibility of mktemp failure.
This commit is contained in:
parent
ef4f3b7334
commit
31870e774a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user