mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-16 23:22:45 +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'
|
function edit_command_buffer --description 'Edit the command buffer in an external editor'
|
||||||
set -l f (mktemp)
|
set -l f (mktemp)
|
||||||
|
or return 1
|
||||||
if set -q f[1]
|
if set -q f[1]
|
||||||
mv $f $f.fish
|
mv $f $f.fish
|
||||||
set f $f.fish
|
set f $f.fish
|
||||||
|
|
|
@ -80,6 +80,7 @@ function funced --description 'Edit function definition'
|
||||||
set -q TMPDIR
|
set -q TMPDIR
|
||||||
or set -l TMPDIR /tmp
|
or set -l TMPDIR /tmp
|
||||||
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
|
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
|
||||||
|
or return 1
|
||||||
set -l tmpname $tmpdir/$funcname.fish
|
set -l tmpname $tmpdir/$funcname.fish
|
||||||
|
|
||||||
if functions -q -- $funcname
|
if functions -q -- $funcname
|
||||||
|
|
|
@ -169,6 +169,7 @@ function help --description 'Show help for the fish shell'
|
||||||
set -q TMPDIR
|
set -q TMPDIR
|
||||||
or set -l TMPDIR /tmp
|
or set -l TMPDIR /tmp
|
||||||
set -l tmpdir (mktemp -d $TMPDIR/help.XXXXXX)
|
set -l tmpdir (mktemp -d $TMPDIR/help.XXXXXX)
|
||||||
|
or return 1
|
||||||
set -l tmpname $tmpdir/help.html
|
set -l tmpname $tmpdir/help.html
|
||||||
echo '<meta http-equiv="refresh" content="0;URL=\''$clean_url'\'" />' >$tmpname
|
echo '<meta http-equiv="refresh" content="0;URL=\''$clean_url'\'" />' >$tmpname
|
||||||
set page_url file://$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
|
# 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/.psub.XXXXXXXXXX)
|
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
||||||
or return
|
or return 1
|
||||||
set filename $dirname/psub.fifo"$_flag_suffix"
|
set filename $dirname/psub.fifo"$_flag_suffix"
|
||||||
command mkfifo $filename
|
command mkfifo $filename
|
||||||
# Note that if we were to do the obvious `cat >$filename &`, we would deadlock
|
# 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 &
|
command tee $filename >/dev/null &
|
||||||
else if test -z "$_flag_suffix"
|
else if test -z "$_flag_suffix"
|
||||||
set filename (mktemp $tmpdir/.psub.XXXXXXXXXX)
|
set filename (mktemp $tmpdir/.psub.XXXXXXXXXX)
|
||||||
|
or return 1
|
||||||
command cat >$filename
|
command cat >$filename
|
||||||
else
|
else
|
||||||
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
set dirname (mktemp -d $tmpdir/.psub.XXXXXXXXXX)
|
||||||
|
or return 1
|
||||||
set filename "$dirname/psub$_flag_suffix"
|
set filename "$dirname/psub$_flag_suffix"
|
||||||
command cat >$filename
|
command cat >$filename
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user