Use :language
command to force C locale
In non-Windows environments, the gpg command is prepended with “LANG=C LC_ALL=C” to ensure gpg's output is consistent to allow for parsing the information. However, that doesn't work in Windows and won't necessarily work if we ever remove the code forcing use of /bin/sh. Since Vim already knows how to influence the environment, use its “:language message …” command to set/restore the locale before/after running the gpg command. Closes jamessan/vim-gnupg#45 Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
parent
8394f2e1b5
commit
89253464f1
@ -1,5 +1,5 @@
|
|||||||
" Name: gnupg.vim
|
" Name: gnupg.vim
|
||||||
" Last Change: 2015 Jul 26
|
" Last Change: 2015 Sep 29
|
||||||
" Maintainer: James McCoy <vega.james@gmail.com>
|
" Maintainer: James McCoy <vega.james@gmail.com>
|
||||||
" Original Author: Markus Braun <markus.braun@krawel.de>
|
" Original Author: Markus Braun <markus.braun@krawel.de>
|
||||||
" Summary: Vim plugin for transparent editing of gpg encrypted files.
|
" Summary: Vim plugin for transparent editing of gpg encrypted files.
|
||||||
@ -320,7 +320,6 @@ function s:GPGInit(bufread)
|
|||||||
let s:shellredir = ">%s 2>&1"
|
let s:shellredir = ">%s 2>&1"
|
||||||
let s:shell = '/bin/sh'
|
let s:shell = '/bin/sh'
|
||||||
let s:stderrredirnull = '2>/dev/null'
|
let s:stderrredirnull = '2>/dev/null'
|
||||||
let s:GPGCommand = "LANG=C LC_ALL=C " . s:GPGCommand
|
|
||||||
else
|
else
|
||||||
" windows specific settings
|
" windows specific settings
|
||||||
let s:shellredir = '>%s'
|
let s:shellredir = '>%s'
|
||||||
@ -1279,16 +1278,29 @@ function s:GPGIDToName(identity)
|
|||||||
return uid
|
return uid
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: s:GPGPreCmd() {{{2
|
||||||
|
"
|
||||||
|
" Setup the environment for running the gpg command
|
||||||
|
"
|
||||||
function s:GPGPreCmd()
|
function s:GPGPreCmd()
|
||||||
let &shellredir = s:shellredir
|
let &shellredir = s:shellredir
|
||||||
let &shell = s:shell
|
let &shell = s:shell
|
||||||
let &shelltemp = s:shelltemp
|
let &shelltemp = s:shelltemp
|
||||||
|
" Force C locale so GPG output is consistent
|
||||||
|
let s:messages = v:lang
|
||||||
|
language messages C
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Function: s:GPGPostCmd() {{{2
|
||||||
|
"
|
||||||
|
" Restore the user's environment after running the gpg command
|
||||||
|
"
|
||||||
function s:GPGPostCmd()
|
function s:GPGPostCmd()
|
||||||
let &shellredir = s:shellredirsave
|
let &shellredir = s:shellredirsave
|
||||||
let &shell = s:shellsave
|
let &shell = s:shellsave
|
||||||
let &shelltemp = s:shelltempsave
|
let &shelltemp = s:shelltempsave
|
||||||
|
execute 'language messages' s:messages
|
||||||
" Workaround a bug in the interaction between console vim and
|
" Workaround a bug in the interaction between console vim and
|
||||||
" pinentry-curses by forcing Vim to re-detect and setup its terminal
|
" pinentry-curses by forcing Vim to re-detect and setup its terminal
|
||||||
" settings
|
" settings
|
||||||
|
Loading…
Reference in New Issue
Block a user