Always handle mktemp failure in user-facing code

mktemp might be missing, see #11972
This commit is contained in:
Johannes Altmanninger
2025-10-22 09:49:45 +02:00
parent 037a399746
commit 034cd7ea35
3 changed files with 8 additions and 3 deletions

View File

@@ -47,13 +47,15 @@ complete -c scp -d "Local Path" -n "not string match @ -- (commandline -ct)"
complete -c scp -d "Remote Path" -f -n "commandline -ct | string match -e ':'" -a '
(__scp_remote_target):(
if not set -q __fish_scp_sftp
set -l tmp (__fish_mktemp_relative fish-scp)
if scp -P(__scp2ssh_port_number) -o "BatchMode yes" -q -O $tmp (__scp_remote_target):/dev/null
if set -l tmp (__fish_mktemp_relative fish-scp)
and scp -P(__scp2ssh_port_number) -o "BatchMode yes" -q -O $tmp (__scp_remote_target):/dev/null
set -g __fish_scp_sftp true
else
set -g __fish_scp_sftp false
end
rm $tmp
if set -q tmp[1]
rm $tmp
end
end
if $__fish_scp_sftp
command ssh -p(__scp2ssh_port_number) -o "BatchMode yes" (__scp_remote_target) command\ ls\ -dp\ (__scp_remote_path_prefix)\* 2>/dev/null

View File

@@ -9,6 +9,7 @@ function __fish_data_with_directory
set directory_ref $__fish_data_dir/$relative_directory
else
set temp (__fish_mktemp_relative -d fish-data)
or return
if set -l paths (status list-files $relative_directory |
string match -r \
"^$(string escape --style=regex $relative_directory)/(?:$file_regex)\$")

View File

@@ -44,12 +44,14 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
break
end
set cursor_from_editor (__fish_mktemp_relative fish-edit_command_buffer)
or return
set -a editor +$line "+norm! $col|" $f \
'+au VimLeave * ++once call writefile([printf("%s %s %s", shellescape(bufname()), line("."), col("."))], "'$cursor_from_editor'")'
case emacs emacsclient gedit
set -a editor +$line:$col $f
case kak
set cursor_from_editor (__fish_mktemp_relative fish-edit_command_buffer)
or return
set -a editor +$line:$col $f -e "
hook -always -once global ClientClose %val{client} %{
echo -to-file $cursor_from_editor -quoting shell \