mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-02 17:43:33 +08:00
Fix #1716 - Replace tempdir() with a wrapper to preserve TMPDIR
This commit is contained in:
@@ -13,7 +13,7 @@ function! s:TemporaryFilename(buffer) abort
|
||||
|
||||
" Create a temporary filename, <temp_dir>/<original_basename>
|
||||
" The file itself will not be created by this function.
|
||||
return tempname() . (has('win32') ? '\' : '/') . l:filename
|
||||
return ale#util#Tempname() . (has('win32') ? '\' : '/') . l:filename
|
||||
endfunction
|
||||
|
||||
" Given a command string, replace every...
|
||||
|
||||
@@ -98,7 +98,7 @@ endfunction
|
||||
|
||||
" Create a new temporary directory and manage it in one go.
|
||||
function! ale#engine#CreateDirectory(buffer) abort
|
||||
let l:temporary_directory = tempname()
|
||||
let l:temporary_directory = ale#util#Tempname()
|
||||
" Create the temporary directory for the file, unreadable by 'other'
|
||||
" users.
|
||||
call mkdir(l:temporary_directory, '', 0750)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
" Description: Error handling for the format GHC outputs.
|
||||
|
||||
" Remember the directory used for temporary files for Vim.
|
||||
let s:temp_dir = fnamemodify(tempname(), ':h')
|
||||
let s:temp_dir = fnamemodify(ale#util#Tempname(), ':h')
|
||||
" Build part of a regular expression for matching ALE temporary filenames.
|
||||
let s:temp_regex_prefix =
|
||||
\ '\M'
|
||||
|
||||
@@ -84,7 +84,7 @@ function! ale#path#IsAbsolute(filename) abort
|
||||
return a:filename[:0] is# '/' || a:filename[1:2] is# ':\'
|
||||
endfunction
|
||||
|
||||
let s:temp_dir = ale#path#Simplify(fnamemodify(tempname(), ':h'))
|
||||
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h'))
|
||||
|
||||
" Given a filename, return 1 if the file represents some temporary file
|
||||
" created by Vim.
|
||||
|
||||
@@ -277,6 +277,25 @@ function! ale#util#InSandbox() abort
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! ale#util#Tempname() abort
|
||||
let l:clear_tempdir = 0
|
||||
|
||||
if has('unix') && empty($TMPDIR)
|
||||
let l:clear_tempdir = 1
|
||||
let $TMPDIR = '/tmp'
|
||||
endif
|
||||
|
||||
try
|
||||
let l:name = tempname() " no-custom-checks
|
||||
finally
|
||||
if l:clear_tempdir
|
||||
let $TMPDIR = ''
|
||||
endif
|
||||
endtry
|
||||
|
||||
return l:name
|
||||
endfunction
|
||||
|
||||
" Given a single line, or a List of lines, and a single pattern, or a List
|
||||
" of patterns, return all of the matches for the lines(s) from the given
|
||||
" patterns, using matchlist().
|
||||
|
||||
Reference in New Issue
Block a user