@@ -257,19 +257,19 @@ graphical interface.
257257"""
258258function getpass end
259259
260- if Sys . iswindows ( )
260+ _getch () = UInt8 ( ccall ( :jl_getch , Cint, ()) )
261261function getpass (input:: TTY , output:: IO , prompt:: AbstractString )
262262 input === stdin || throw (ArgumentError (" getpass only works for stdin" ))
263263 print (output, prompt, " : " )
264264 flush (output)
265265 s = SecretBuffer ()
266266 plen = 0
267267 while true
268- c = UInt8 ( ccall ( : _getch, Cint, ()) )
269- if c == 0xff || c == UInt8 (' \n ' ) || c == UInt8 (' \r ' )
268+ c = _getch ( )
269+ if c == 0xff || c == UInt8 (' \n ' ) || c == UInt8 (' \r ' ) || c == 0x04
270270 break # EOF or return
271271 elseif c == 0x00 || c == 0xe0
272- ccall ( : _getch, Cint, () ) # ignore function/arrow keys
272+ _getch ( ) # ignore function/arrow keys
273273 elseif c == UInt8 (' \b ' ) && plen > 0
274274 plen -= 1 # delete last character on backspace
275275 elseif ! iscntrl (Char (c)) && plen < 128
@@ -278,13 +278,6 @@ function getpass(input::TTY, output::IO, prompt::AbstractString)
278278 end
279279 return seekstart (s)
280280end
281- else
282- function getpass (input:: TTY , output:: IO , prompt:: AbstractString )
283- (input === stdin && output === stdout ) || throw (ArgumentError (" getpass only works for stdin" ))
284- msg = string (prompt, " : " )
285- unsafe_SecretBuffer! (ccall (:getpass , Cstring, (Cstring,), msg))
286- end
287- end
288281
289282# allow new getpass methods to be defined if stdin has been
290283# redirected to some custom stream, e.g. in IJulia.
0 commit comments