aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/getenv.vim
blob: 3b5f4c1bdab95753bd531aa57a3ee8686d2609d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
" Backport getenv() from v8.1.1305, except return an empty string rather than
" v:null
"
" <https://github.com/vim/vim/releases/tag/v8.1.1305>
"
function! getenv#(name) abort

  if a:name !~# '^[A-Z][A-Z0-9_]*$'
    throw 'Illegal env var name'
  endif
  let value = ''
  if exists('$'.a:name)
    execute 'let value = $'.a:name
  endif
  return value

endfunction