You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpectedly changed the output code page when calling the ssh, ssh-keygen, scp, sftp command. #2027
But then I realized may be not, as msetlocale() also gets called not only in ssh, but also in scp, sftp, ssh-keygen, which probably don't open a raw-mode console. I suspect msetlocale(), which gets called earlier, should query with GetConsoleOutputCP the prior state. It can't return that state, such that the caller could restore the prior state, e.g. in a function registered with atexit(), because the original utf8.c:msetlocale() is a wrapper around setlocale() that doesn't save any state, because on Unix setlocale doesn't change any state outside the current process, unlike SetConsoleOutputCP, which does affect the console state beyond the lifetime of the current process. So perhaps registering an atexit() function to restore the CP state from within contrib/win32/win32compat/win32-utf8.c:msetlocale() is a better thing to do here?
I wrote a workaround to address the #2027 issue.
The compilation was successful and confirmed that the event could be avoided. PowerShell/openssh-portable#666
Activity
kemaruya commentedon Feb 1, 2023
The issue was caused by the following pull request.
Allow Console Output In UTF-8 by NoMoreFood · Pull Request #378 · PowerShell/openssh-portable (github.com)
mgkuhn commentedon Feb 17, 2023
Bryan Berns (@NoMoreFood) I first wondered if your calling SetConsoleOutputCP() (without saving the previous state first with GetConsoleOutputCP) in contrib/win32/win32compat/win32-utf8.c:msetlocale() isn't redundant, given that there also has been code to do all that in contrib/win32/win32compat/console.c:ConEnterRawMode() since PowerShell/openssh-portable@84e87be which does save and restore the prior state?
But then I realized may be not, as
msetlocale()also gets called not only inssh, but also inscp,sftp,ssh-keygen, which probably don't open a raw-mode console. I suspect msetlocale(), which gets called earlier, should query with GetConsoleOutputCP the prior state. It can't return that state, such that the caller could restore the prior state, e.g. in a function registered with atexit(), because the original utf8.c:msetlocale() is a wrapper around setlocale() that doesn't save any state, because on Unix setlocale doesn't change any state outside the current process, unlike SetConsoleOutputCP, which does affect the console state beyond the lifetime of the current process. So perhaps registering an atexit() function to restore the CP state from within contrib/win32/win32compat/win32-utf8.c:msetlocale() is a better thing to do here?kemaruya commentedon Feb 28, 2023
I wrote a workaround to address the #2027 issue.
The compilation was successful and confirmed that the event could be avoided.
PowerShell/openssh-portable#666